@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Inter:wght@400;700&family=Outfit:wght@400;700&family=Press+Start+2P&family=Roboto:wght@400;700&display=swap');

/* --- 🎨 THEME ENGINE --- */
:root {
    --bg-color: #f4f7f6;
    --container-bg: #ffffff;
    --text-color: #333333;
    --accent-color: #2c3e50;
    --nav-bg: #ffffff;
    --btn-add: #3498db;
    --btn-remove: #e74c3c;
    --btn-go: #27ae60;
    --btn-instant: #f1c40f;
    --btn-share: #9b59b6;
    --winner-glow: #2ecc71;
    --font-main: 'Segoe UI', Tahoma, sans-serif;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --container-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --accent-color: #bb86fc;
    --nav-bg: #1e1e1e;
    --btn-add: #03dac6;
    --btn-remove: #cf6679;
    --btn-go: #bb86fc;
    --btn-instant: #f39c12;
    --winner-glow: #03dac6;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --container-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --accent-color: #bb86fc;
    --nav-bg: #1e1e1e;
    --btn-add: #03dac6;
    --btn-remove: #cf6679;
    --btn-go: #bb86fc;
    --btn-instant: #f39c12;
    --winner-glow: #03dac6;
}

[data-theme="classroom"] {
    --bg-color: #3e5f44;
    --container-bg: #fdf6e3;
    --text-color: #2c3e50;
    --accent-color: #d35400;
    --nav-bg: #fdf6e3;
    --btn-go: #e67e22;
}

[data-theme="gaming"] {
    --bg-color: #2c003e;
    --container-bg: #4c0070;
    --text-color: #00ff00;
    --accent-color: #ff00ff;
    --nav-bg: #000000;
    --btn-go: #ff00ff;
    --winner-glow: #00ff00;
}

[data-theme="holiday"] {
    --bg-color: #c0392b;
    --container-bg: #ffffff;
    --text-color: #16a085;
    --accent-color: #c0392b;
    --nav-bg: #ffffff;
    --btn-go: #27ae60;
    --winner-glow: #f1c40f;
}

[data-theme="rainbow"] {
    animation: rainbowBG 5s infinite alternate;
    --container-bg: rgba(255, 255, 255, 0.9);
    --text-color: #000;
}

@keyframes rainbowBG {
    0% {
        background-color: #ff0000;
    }

    20% {
        background-color: #ff9900;
    }

    40% {
        background-color: #ffff00;
    }

    60% {
        background-color: #33cc33;
    }

    80% {
        background-color: #3399ff;
    }

    100% {
        background-color: #cc33cc;
    }
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    padding-bottom: 80px;
    transition: all 0.3s ease;
    overflow-x: hidden;
    position: relative;
}

/* --- 🌫️ BACKGROUND MOTION --- */
.bg-motion {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.4;
}

.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: float 20s infinite alternate ease-in-out;
}

.shape1 {
    width: 400px;
    height: 400px;
    background: var(--accent-color);
    top: -100px;
    left: -100px;
    opacity: 0.3;
}

.shape2 {
    width: 500px;
    height: 500px;
    background: var(--btn-add);
    bottom: -150px;
    right: -150px;
    opacity: 0.2;
    animation-delay: -5s;
}

.shape3 {
    width: 300px;
    height: 300px;
    background: var(--btn-instant);
    top: 50%;
    left: 60%;
    opacity: 0.15;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    33% {
        transform: translate(30px, 50px) scale(1.1) rotate(10deg);
    }

    66% {
        transform: translate(-20px, 80px) scale(0.9) rotate(-10deg);
    }

    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
}

/* NAV */
.top-nav {
    background: var(--nav-bg);
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    border-radius: 20px;
    transition: all 0.2s;
    opacity: 0.7;
}

.nav-btn:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.1);
}

.nav-btn.active {
    opacity: 1;
    background-color: var(--btn-add);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .top-nav {
        display: none;
    }
}

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--nav-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    justify-content: space-around;
    padding: 12px 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }
}

.mob-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    color: var(--text-color);
    opacity: 0.6;
    padding: 5px 10px;
    flex: 1;
}

.mob-btn.active {
    opacity: 1;
    color: var(--btn-add);
    transform: scale(1.05);
}

.mob-btn span {
    font-size: 22px;
    margin-bottom: 4px;
}

/* CONTENT */
.tab-content {
    display: none;
    max-width: 600px;
    margin: 20px auto;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-wrapper {
    background: var(--container-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* INPUTS */
.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

input[type="text"] {
    flex-grow: 1;
    padding: 12px;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    background: var(--bg-color);
    color: var(--text-color);
}

input[type="text"]:focus {
    border-color: var(--btn-add);
    outline: none;
}

input:disabled {
    background-color: rgba(0, 0, 0, 0.05);
    color: #888;
    border-color: #eee;
    cursor: not-allowed;
}

.btn-lock {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.btn-lock:hover {
    opacity: 1;
}

.duplicate input {
    border-color: #e67e22;
    background: #fff3e0;
    color: #333;
}

.input-row.winner input {
    background-color: var(--nav-bg);
    border-color: var(--winner-glow);
    box-shadow: 0 0 20px var(--winner-glow);
    transform: scale(1.05);
    font-weight: bold;
}

/* STAGE */
.stage-area {
    height: 200px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin: 20px 0;
}

#handImage {
    width: 100px;
    transition: transform 1s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: bottom center;
    z-index: 100;
    position: relative;
}

.dancing {
    animation: handBob 0.53s infinite alternate ease-in-out;
}

@keyframes handBob {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(-15deg) scale(1.1);
    }

    100% {
        transform: rotate(15deg) scale(1.1);
    }
}

/* --- 🪙 COIN FLIP --- */
.coin-container {
    perspective: 1000px;
    width: 100px;
    height: 100px;
    display: none;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

.coin {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    border: 4px solid #f1c40f;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.5);
    font-weight: bold;
    background: #f39c12;
    color: #fff;
}

.coin-back {
    transform: rotateY(180deg);
    background: #e67e22;
}

.coin.flip-heads {
    transform: rotateY(1800deg);
}

/* 5 full rotations */
.coin.flip-tails {
    transform: rotateY(1980deg);
}

/* --- 🎡 SPINNER WHEEL --- */
.wheel-container {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 0 auto;
    z-index: 10;
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.5);
    border: 5px solid #fff;
    background: #fff;
    transition: transform 4s cubic-bezier(0.1, 0, 0.1, 1);
}

.wheel-pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 40px;
    background: #e74c3c;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    z-index: 20;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* BUTTONS */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    font-family: inherit;
    margin: 5px 0;
    transition: transform 0.1s, filter 0.2s;
}

.btn:hover {
    filter: brightness(1.1);
}

.btn:active {
    transform: scale(0.95);
}

.btn-add {
    background: var(--btn-add);
}

.btn-remove {
    background: var(--btn-remove);
    padding: 5px 12px;
    margin: 0;
}

.btn-reset {
    background: #95a5a6;
}

.btn-save {
    background: #f39c12;
    font-size: 12px;
}

.action-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-go {
    background: var(--btn-go);
    flex-grow: 2;
    font-size: 18px;
    padding: 15px;
}

.btn-instant {
    background: var(--btn-instant);
    flex-grow: 1;
    color: #333;
    font-size: 14px;
}

.btn-share {
    background: var(--btn-share);
    width: 100%;
    margin-top: 10px;
    display: none;
}

.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.theme-btn {
    padding: 15px;
    border: 2px solid #ccc;
    cursor: pointer;
    border-radius: 8px;
    font-weight: bold;
}

/* SKIN SELECTOR */
.skin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.skin-btn {
    background: var(--nav-bg);
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.skin-btn:hover {
    border-color: var(--btn-add);
    transform: translateY(-2px);
}

.skin-btn.active {
    border-color: var(--btn-add);
    box-shadow: 0 0 10px var(--btn-add);
}

.skin-btn img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.skin-btn span {
    font-size: 10px;
    font-weight: bold;
    color: var(--text-color);
}

/* HISTORY */
#statusText {
    margin-top: 15px;
    font-weight: bold;
    min-height: 24px;
    color: var(--accent-color);
}

.history-item {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 5px;
    text-align: left;
}

.placeholder-box {
    border: 2px dashed #ccc;
    padding: 30px;
    border-radius: 10px;
    color: #888;
    margin-top: 10px;
}

.fairness-badge {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
    background: rgba(0, 0, 0, 0.05);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
}

.confetti {
    position: fixed;
    top: 0;
    width: 10px;
    height: 10px;
    background-color: #f00;
    animation: fall linear forwards;
    z-index: 2000;
    pointer-events: none;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

/* MASTER SWITCHES */
.switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    font-weight: bold;
}

.switch-label input {
    display: none;
}

.slider {
    width: 44px;
    height: 24px;
    background: #ccc;
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background: #2ecc71;
}

input:checked+.slider::before {
    transform: translateX(20px);
}

body.locks-hidden .btn-lock-icon {
    display: none !important;
}

body.shields-hidden .btn-shield-icon {
    display: none !important;
}

/* --- 🎭 SECRETS UNLOCK ANIMATION --- */
@keyframes btn-success-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    }

    50% {
        transform: scale(0.95);
        box-shadow: 0 0 0 10px rgba(39, 174, 96, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0);
    }
}

.btn-pulse {
    animation: btn-success-pulse 0.4s ease-out !important;
}

/* WEIGHT SLIDERS */
.weight-item {
    background: rgba(0, 0, 0, 0.03);
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid var(--btn-add);
}

.weight-header {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
}

input[type=range] {
    width: 100%;
    cursor: pointer;
}

/* 🟢 NEW: MOBILE-ONLY MENU LOGIC */

/* 1. By default (Computers), hide this section completely */
.mobile-only-section {
    display: none;
}

/* 2. On Small Screens (Phones), show it */
@media (max-width: 768px) {
    .mobile-only-section {
        display: block;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
}

/* MODAL SYSTEM */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}