        /* =====================================================================
         * THEME TOKENS — Change colors here, they cascade everywhere
         * ===================================================================== */
        :root {
            --bg-color: #12161a;
            --panel-bg: #222831;
            --accent-yellow: #FFD200;
            --accent-red: #FF4136;
            --accent-blue: #0074D9;
            --text-light: #F5F5F5;

            --tile-neutral: #00A3E0;
            --tile-challenge: #FF851B;
            --tile-item: #2ECC40;
            --tile-trivia: #B10DC9;
            --tile-unlucky: #FF4136;
        }

        body {
            font-family: 'Fredoka', sans-serif;
            background-color: var(--bg-color);
            color: var(--text-light);
            margin: 0;
            padding: 10px;
            display: flex;
            flex-direction: column;
            align-items: center;
            user-select: none;
            overflow: hidden;
        }

        h1 {
            font-family: 'Sniglet', cursive;
            color: var(--accent-yellow);
            text-shadow: 3px 3px 0px #000;
            margin: 5px 0 10px 0;
            font-size: 2rem;
            text-align: center;
            letter-spacing: 2px;
        }

        .game-container {
            display: grid;
            grid-template-columns: 380px 1fr;
            gap: 15px;
            width: 100%;
            max-width: 1600px;
            height: calc(100vh - 70px);
        }

        .sidebar {
            background-color: var(--panel-bg);
            border: 4px solid #393E46;
            border-radius: 15px;
            padding: 15px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            overflow-y: auto;
            box-shadow: 5px 5px 0px #000;
        }

        .panel-section {
            background: rgba(0,0,0,0.2);
            border-radius: 10px;
            padding: 12px;
            border-left: 5px solid var(--accent-yellow);
        }

        .panel-section h2 {
            margin: 0 0 8px 0;
            font-size: 1.1rem;
            color: var(--accent-yellow);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .player-status-card {
            background: #2d343f;
            border: 3px solid #393E46;
            border-radius: 8px;
            padding: 8px;
            margin-bottom: 6px;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .player-status-card.active {
            border-color: var(--accent-yellow);
            box-shadow: 0 0 8px var(--accent-yellow);
        }

        .player-header {
            display: flex;
            justify-content: space-between;
            font-weight: 900;
        }

        .player-stats {
            display: grid;
            grid-template-columns: 1fr 1fr;
            font-size: 0.85rem;
            color: #ccc;
        }

        button {
            font-family: 'Fredoka', sans-serif;
            background-color: var(--accent-blue);
            color: white;
            border: none;
            border-bottom: 4px solid rgba(0,0,0,0.4);
            border-radius: 8px;
            padding: 10px 12px;
            font-size: 0.95rem;
            font-weight: bold;
            cursor: pointer;
        }
        button:active {
            transform: translateY(2px);
            border-bottom-width: 2px;
        }
        button:disabled {
            background-color: #555 !important;
            border-bottom: 2px solid #333;
            cursor: not-allowed;
        }

        .action-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

        .btn-roll { background-color: var(--accent-red); position: relative; }
        .btn-trade { background-color: var(--tile-item); }

        .board-wrapper {
            background-color: var(--panel-bg);
            border: 4px solid #393E46;
            border-radius: 15px;
            box-shadow: 5px 5px 0px #000;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        .board-header-info {
            background: rgba(0,0,0,0.4);
            padding: 8px;
            display: flex;
            justify-content: space-around;
            font-size: 0.85rem;
            border-bottom: 2px solid #393E46;
            flex-wrap: wrap;
            gap: 5px;
        }

        .legend-item { display: flex; align-items: center; gap: 4px; }
        .legend-dot { width: 12px; height: 12px; border-radius: 3px; }

        .find-player-bar {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 8px;
            padding: 8px;
            background: rgba(0,0,0,0.25);
            border-bottom: 2px solid #393E46;
        }

        .find-player-btn {
            font-family: 'Fredoka', sans-serif;
            font-weight: 900;
            font-size: 0.85rem;
            padding: 7px 14px;
            border: none;
            border-bottom: 4px solid rgba(0,0,0,0.4);
            border-radius: 8px;
            color: #12161a;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .find-player-btn:active {
            transform: translateY(2px);
            border-bottom-width: 2px;
        }
        .find-player-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .find-player-btn .fpb-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: rgba(0,0,0,0.35);
            flex-shrink: 0;
        }

        .settings-menu-wrapper {
            position: fixed;
            top: 12px;
            right: 12px;
            z-index: 200;
        }

        .settings-gear-btn {
            background-color: var(--panel-bg);
            border: 3px solid #393E46;
            border-radius: 50%;
            width: 44px;
            height: 44px;
            font-size: 1.3rem;
            padding: 0;
            line-height: 1;
            box-shadow: 3px 3px 0px #000;
        }

        .settings-dropdown {
            display: none;
            position: absolute;
            top: 52px;
            right: 0;
            background-color: var(--panel-bg);
            border: 3px solid #393E46;
            border-radius: 10px;
            box-shadow: 5px 5px 0px #000;
            padding: 10px;
            min-width: 200px;
            flex-direction: column;
            gap: 8px;
        }

        .settings-dropdown.open { display: flex; }

        .settings-dropdown-item {
            width: 100%;
            background-color: var(--accent-red);
            text-align: center;
        }

        .board-scroll-container {
            flex: 1;
            overflow: auto;
            padding: 20px;
            position: relative;
            background: #161a22;
        }

        .board-canvas-layer {
            position: relative;
            width: 5000px;
            height: 950px;
        }

        .board-tile {
            position: absolute;
            width: 65px;
            height: 65px;
            border-radius: 10px;
            border-bottom: 4px solid rgba(0,0,0,0.3);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            font-size: 0.65rem;
            font-weight: bold;
            color: white;
            text-shadow: 1px 1px 2px #000;
            box-sizing: border-box;
            box-shadow: 0 3px 5px rgba(0,0,0,0.4);
            text-align: center;
            padding: 2px;
            transition: background-color 0.2s;
        }

        .tile-label { font-size: 0.6rem; opacity: 0.9; word-break: break-all; }

        .token-container {
            display: flex;
            justify-content: center;
            gap: 2px;
            flex-wrap: wrap;
            width: 100%;
            margin-top: 2px;
        }
        .player-token {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            border: 1.5px solid white;
            box-shadow: 0 1px 3px rgba(0,0,0,0.6);
            transition: all 0.2s ease-in-out;
        }
        .player-token.token-hidden { opacity: 0; }

        /* =====================================================================
         * SWITCH-PLACES ANIMATION — flying tokens, tile glow, and a banner so
         * a position swap is obvious without reading the log or step count.
         * ===================================================================== */
        .swap-banner {
            position: absolute;
            top: 14px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 160;
            display: none;
            align-items: center;
            gap: 10px;
            background: var(--panel-bg);
            color: var(--text-light);
            border: 3px solid var(--accent-yellow);
            border-radius: 50px;
            padding: 8px 20px;
            box-shadow: 4px 4px 0px #000;
            font-family: 'Sniglet', cursive;
            font-size: 1rem;
            pointer-events: none;
            white-space: nowrap;
        }
        .swap-banner.visible { display: flex; animation: swapBannerPulse 0.9s ease-in-out infinite; }
        .swap-banner .swap-icon { font-size: 1.3rem; display: inline-block; animation: swapIconSpin 0.8s linear infinite; }
        @keyframes swapIconSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
        @keyframes swapBannerPulse {
            0%, 100% { box-shadow: 4px 4px 0px #000; }
            50%      { box-shadow: 4px 4px 0px #000, 0 0 18px 4px var(--accent-yellow); }
        }

        .board-tile.swap-glow {
            animation: swapTileGlow 0.6s ease-in-out infinite;
            z-index: 5;
        }
        @keyframes swapTileGlow {
            0%, 100% { box-shadow: 0 3px 5px rgba(0,0,0,0.4), 0 0 0px 0px var(--glow-color, #fff); transform: scale(1); }
            50%      { box-shadow: 0 3px 5px rgba(0,0,0,0.4), 0 0 16px 6px var(--glow-color, #fff); transform: scale(1.08); }
        }

        .swap-flying-token {
            position: absolute;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            border: 3px solid white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.75rem;
            font-weight: 900;
            color: #12161a;
            z-index: 50;
            pointer-events: none;
            transition: left 0.85s cubic-bezier(.34,1.56,.64,1), top 0.85s cubic-bezier(.34,1.56,.64,1);
            box-shadow: 0 0 10px 3px rgba(255,255,255,0.5);
        }
        .swap-flying-token.flying { animation: swapHopArc 0.85s ease-in-out; }
        @keyframes swapHopArc {
            0%   { transform: translateY(0) scale(1); }
            50%  { transform: translateY(-46px) scale(1.15); }
            100% { transform: translateY(0) scale(1); }
        }

        .modal-overlay {
            position: absolute;
            top: 20px; right: 20px;
            width: 380px;
            background: transparent;
            backdrop-filter: none;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 100;
            opacity: 0; pointer-events: none;
            transition: opacity 0.2s ease;
        }
        .modal-overlay.open { opacity: 1; pointer-events: auto; }

        .card-popup {
            background: rgba(34, 40, 49, 0.98);
            color: #fff;
            width: 100%;
            border-radius: 16px;
            padding: 20px;
            text-align: center;
            box-shadow: 0 10px 30px rgba(0,0,0,0.7);
            border: 4px solid var(--accent-yellow);
            transform: scale(0.9);
            transition: transform 0.2s ease;
        }
        .modal-overlay.open .card-popup { transform: scale(1); }

        .card-type-banner {
            font-size: 1.2rem; font-weight: 900; color: white;
            padding: 6px; border-radius: 8px; margin-bottom: 12px;
            text-shadow: 1px 1px 2px #000;
        }
        .card-text { font-size: 1rem; margin-bottom: 15px; line-height: 1.4; font-weight: 700; }

        .modal-buttons {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .game-logs {
            flex: 1; background: rgba(0,0,0,0.4); border-radius: 8px;
            padding: 8px; font-size: 0.8rem; font-family: monospace;
            overflow-y: auto; max-height: 140px; border: 1px solid #393E46;
            color: #adfa1d;
        }
        .log-entry { margin-bottom: 4px; border-bottom: 1px solid #2d343f; padding-bottom: 2px; }

        .setup-screen {
            position: fixed; top:0; left:0; right:0; bottom:0;
            background: #161a22; z-index: 200;
            display: flex; flex-direction: column; justify-content: flex-start; align-items: center;
            overflow-y: auto; box-sizing: border-box; padding: 30px 10px;
        }
        .setup-box {
            background: var(--panel-bg); border: 4px solid var(--accent-yellow);
            border-radius: 15px; padding: 25px; width: 440px; max-width: 100%;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            box-sizing: border-box;
        }
        .setup-box input, .setup-box select {
            width: 100%; padding: 8px; margin: 6px 0 14px 0;
            border-radius: 6px; border: 2px solid #555; background: #12161a; color: white;
            box-sizing: border-box; font-family: 'Fredoka';
        }

        /* =====================================================================
         * CHALLENGE CUSTOMIZATION (setup screen)
         * ===================================================================== */
        .challenge-cat-block {
            background: rgba(0,0,0,0.2);
            border-radius: 10px;
            margin-bottom: 8px;
            overflow: hidden;
        }
        .challenge-cat-header {
            display: flex; justify-content: space-between; align-items: center;
            padding: 8px 10px; border-left: 4px solid var(--accent-yellow);
            gap: 8px;
        }
        .cat-toggle-switch { display: flex; align-items: flex-start; gap: 8px; flex: 1; }
        .cat-toggle-switch input[type="checkbox"] { width: auto; margin: 3px 0 0 0; flex-shrink: 0; }
        .challenge-cat-title { font-weight: 900; font-size: 0.9rem; }
        .challenge-cat-sub { font-size: 0.72rem; color: #aaa; font-weight: 400; line-height: 1.3; margin-top: 2px; }
        .challenge-cat-expand-btn {
            padding: 4px 9px; font-size: 0.75rem; border-bottom-width: 3px; flex-shrink: 0;
        }
        .challenge-list { padding: 6px 10px 10px 10px; }
        .select-all-row { display: flex; gap: 6px; margin-bottom: 8px; }
        .select-all-row button {
            flex: 1; font-size: 0.7rem; padding: 5px; background: #3a4149;
            border-bottom: 2px solid rgba(0,0,0,0.4);
        }
        .challenge-item-row {
            display: flex; align-items: flex-start; gap: 8px; padding: 5px 2px;
            font-size: 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.06);
        }
        .challenge-item-row:last-of-type { border-bottom: none; }
        .challenge-item-row input[type="checkbox"] { width: auto; margin: 3px 0 0 0; flex-shrink: 0; }
        .challenge-item-row label { flex: 1; cursor: pointer; line-height: 1.35; }
        .remove-custom-btn {
            background: var(--accent-red); border: none; color: white; border-radius: 5px;
            width: 22px; height: 22px; line-height: 1; cursor: pointer; font-size: 0.75rem;
            padding: 0; flex-shrink: 0; border-bottom: 2px solid rgba(0,0,0,0.4);
        }
        .add-challenge-row { display: flex; gap: 6px; margin-top: 8px; }
        .add-challenge-row input { flex: 1; margin: 0; padding: 6px 8px; font-size: 0.78rem; }
        .add-challenge-row button { padding: 6px 10px; font-size: 0.75rem; white-space: nowrap; }
        .challenge-customize-intro { font-size: 0.8rem; color: #aaa; margin: 0 0 12px 0; text-align: center; line-height: 1.4; }

        .dice-visualizer {
            display: inline-block;
            width: 40px;
            height: 40px;
            line-height: 40px;
            background: white;
            color: black;
            border-radius: 8px;
            font-size: 1.5rem;
            font-weight: 900;
            margin-bottom: 10px;
            box-shadow: 0 4px 0px #ccc;
        }
        .rolling {
            animation: shake 0.15s infinite alternate;
        }
        @keyframes shake {
            0% { transform: rotate(-10deg); }
            100% { transform: rotate(10deg); }
        }

        /* =====================================================================
         * MARIO-PARTY STYLE DICE MERGE ANIMATION
         * Used for: multiple dice (Double/Triple Dice) combining into a total,
         * and Mushroom bonus (+5) merging into a die roll.
         * ===================================================================== */
        .dice-merge-row {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            min-height: 70px;
            margin-bottom: 6px;
        }
        .dice-merge-die {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 50px;
            height: 50px;
            background: white;
            color: #222;
            border-radius: 10px;
            font-size: 1.6rem;
            font-weight: 900;
            box-shadow: 0 4px 0px #ccc;
            transition: transform 0.4s ease, opacity 0.4s ease;
        }
        .dice-merge-die.mushroom-die {
            background: linear-gradient(180deg, #ff5b5b 0%, #e63946 60%);
            color: white;
            box-shadow: 0 4px 0px #a12630;
        }
        .dice-merge-plus {
            font-size: 1.8rem;
            font-weight: 900;
            color: var(--accent-yellow, #ffcc33);
            transition: opacity 0.3s ease;
        }
        .dice-merge-die.merging {
            animation: mergeFly 0.5s ease forwards;
        }
        .dice-merge-plus.merging-out {
            animation: fadeShrink 0.4s ease forwards;
        }
        @keyframes mergeFly {
            0%   { transform: translateX(0) scale(1); }
            60%  { transform: translateX(var(--merge-x, 0px)) scale(1.15); }
            100% { transform: translateX(var(--merge-x, 0px)) scale(0); opacity: 0; }
        }
        @keyframes fadeShrink {
            0%   { transform: scale(1); opacity: 1; }
            100% { transform: scale(0.2); opacity: 0; }
        }
        .dice-merge-total {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 64px;
            height: 64px;
            background: var(--accent-yellow, #ffcc33);
            color: #222;
            border-radius: 12px;
            font-size: 2rem;
            font-weight: 900;
            box-shadow: 0 5px 0px #b8901c;
            transform: scale(0);
            animation: popIn 0.35s ease forwards;
        }
        @keyframes popIn {
            0%   { transform: scale(0); }
            70%  { transform: scale(1.2); }
            100% { transform: scale(1); }
        }

        /* =====================================================================
         * STEP COUNTER — Mario-Party-style "steps remaining" badge that
         * floats above the board while a player is moving.
         * ===================================================================== */
        .step-counter-badge {
            position: absolute;
            top: 14px;
            left: 50%;
            transform: translateX(-50%) scale(1);
            z-index: 150;
            display: none;
            align-items: center;
            gap: 8px;
            background: var(--accent-yellow);
            color: #12161a;
            border: 3px solid #000;
            border-radius: 50px;
            padding: 6px 18px 6px 10px;
            box-shadow: 4px 4px 0px #000;
            font-family: 'Sniglet', cursive;
            pointer-events: none;
        }
        .step-counter-badge.visible { display: flex; }
        .step-counter-badge .step-counter-boot { font-size: 1.3rem; }
        .step-counter-badge .step-counter-value {
            font-size: 1.6rem;
            min-width: 1.4ch;
            text-align: center;
            display: inline-block;
        }
        .step-counter-badge .step-counter-label {
            font-family: 'Fredoka', sans-serif;
            font-size: 0.75rem;
            font-weight: 900;
            color: #12161a;
            opacity: 0.75;
            letter-spacing: 1px;
        }
        .step-counter-badge.pop .step-counter-value {
            animation: stepCounterPop 0.28s ease-out;
        }
        @keyframes stepCounterPop {
            0%   { transform: scale(1.6); color: var(--accent-red); }
            100% { transform: scale(1); color: #12161a; }
        }
        .step-counter-badge.entering {
            animation: stepCounterEnter 0.22s ease-out;
        }
        @keyframes stepCounterEnter {
            0%   { transform: translateX(-50%) scale(0.4); opacity: 0; }
            100% { transform: translateX(-50%) scale(1); opacity: 1; }
        }