* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Generic hidden state. More specific rules below (e.g. .win-screen-panel.hidden,
   .modal.hidden) add their own transition/opacity behavior on top of this, but
   every element using a bare .hidden class needs this base rule to actually
   disappear — without it, toggling .hidden on a plain div does nothing. */
.hidden {
    display: none !important;
}

.splash-screen {
    position: fixed; inset: 0; background: #0d291c; z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.splash-icon {
    width: 96px; height: 96px; border-radius: 22px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: splashPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.splash-title {
    font-family: 'Baloo 2', 'Quicksand', sans-serif; font-size: 1.7rem; font-weight: 800; color: #fff;
    opacity: 0; animation: splashFadeIn 0.5s ease 0.25s forwards;
}
@keyframes splashPop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes splashFadeIn { to { opacity: 1; } }
.splash-screen.hide { opacity: 0; visibility: hidden; pointer-events: none; }

/* Reduced motion: respects the OS-level preference automatically, and the
   in-game Settings toggle lets a player opt in even if their OS doesn't
   expose the preference (common on some Android WebViews). */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0.001ms !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

.game-header h1, .win-screen-panel h2, .modal-content h2, .puzzle-info,
.target-box .target-val, .value, .timer-val,
.card .center-val, .card .corner-tl, .card .corner-br,
.action-btn, .ctrl-btn, .symbol-btn, .cal-arrow-btn,
.par-indicator strong, #stat-streak, #stat-played, .star-rating {
    font-family: 'Baloo 2', 'Quicksand', sans-serif;
}

body {
    background-color: #060907;
    color: #e1e1e6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    touch-action: manipulation;
}

.page-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 36px;
    width: 100%;
}

.side-panel {
    display: none;
    width: 240px;
    flex-shrink: 0;
    flex-direction: column;
    color: #e5e7eb;
}
.side-logo { font-size: 2.4rem; margin-bottom: 6px; }
.side-title { font-family: 'Baloo 2', sans-serif; font-size: 1.6rem; font-weight: 800; color: #fff; margin-bottom: 4px; }
.side-tagline { font-size: 0.85rem; color: #a7f3d0; margin-bottom: 20px; line-height: 1.4; }
.side-feature-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.side-feature-list li { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: #d1d5db; }
.feature-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 8px var(--accent); }

.side-panel-heading { font-family: 'Baloo 2', sans-serif; font-size: 0.95rem; color: #fde68a; margin-bottom: 12px; }
.stat-row {
    display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08); color: #d1d5db;
}
.stat-row strong { font-family: 'Baloo 2', sans-serif; color: #fff; font-size: 0.95rem; }
.side-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 20px 0; }
.side-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.legend-chip {
    width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem;
    font-family: 'Baloo 2', sans-serif;
}

@media (min-width: 900px) {
    .side-panel { display: flex; }
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    max-height: 850px;
    background-color: #0d381f;
    background-image: 
        radial-gradient(circle at 50% 12%, rgba(74, 222, 128, 0.22) 0%, transparent 55%),
        radial-gradient(circle at center, #1e5f38 0%, #0d381f 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255,255,255,0.08), 0 0 60px rgba(0,0,0,0.5);
    overflow: hidden;
    transition: background 0.3s ease;
}
/* Ambient texture drift, isolated onto its own layer so the animation only
   ever touches `transform` (compositor-only, cheap even on old hardware)
   instead of animating background-position on the whole container, which
   would force a continuous repaint of the entire viewport every frame for
   the full session. Oversized so drifting never exposes an edge. */
.game-container > * {
    position: relative;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -15%; left: -15%; width: 130%; height: 130%;
    background-image: url("data:image/svg+xml,%3Csvg%20width%3D%27200%27%20height%3D%27200%27%20viewBox%3D%270%200%20200%20200%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cg%20fill%3D%27%23ffffff%27%20fill-opacity%3D%270.07%27%20font-family%3D%27sans-serif%27%20font-weight%3D%27800%27%3E%3Ctext%20x%3D%2720%27%20y%3D%2755%27%20font-size%3D%2734%27%3E%2B%3C%2Ftext%3E%3Ctext%20x%3D%27140%27%20y%3D%2765%27%20font-size%3D%2730%27%3E%26%23215%3B%3C%2Ftext%3E%3Ctext%20x%3D%2775%27%20y%3D%27150%27%20font-size%3D%2734%27%3E-%3C%2Ftext%3E%3Ctext%20x%3D%27150%27%20y%3D%27175%27%20font-size%3D%2728%27%3E%26%23247%3B%3C%2Ftext%3E%3Ctext%20x%3D%2740%27%20y%3D%27185%27%20font-size%3D%2728%27%3E%25%3C%2Ftext%3E%3Ctext%20x%3D%27165%27%20y%3D%27100%27%20font-size%3D%2726%27%3E%3D%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E");
    background-repeat: repeat;
    animation: bgDrift 100s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}
@keyframes bgDrift {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-24px, -16px); }
}

body {
    background-color: #060b08;
    background-image:
        radial-gradient(circle at 50% 45%, rgba(52, 211, 153, 0.14) 0%, transparent 45%),
        url("data:image/svg+xml,%3Csvg%20width%3D%27320%27%20height%3D%27320%27%20viewBox%3D%270%200%20320%20320%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cg%20fill%3D%27%23ffffff%27%20fill-opacity%3D%270.035%27%20font-family%3D%27sans-serif%27%20font-weight%3D%27800%27%3E%3Ctext%20x%3D%2730%27%20y%3D%2780%27%20font-size%3D%2754%27%3E%2B%3C%2Ftext%3E%3Ctext%20x%3D%27220%27%20y%3D%27100%27%20font-size%3D%2748%27%3E%26%23215%3B%3C%2Ftext%3E%3Ctext%20x%3D%27120%27%20y%3D%27230%27%20font-size%3D%2754%27%3E-%3C%2Ftext%3E%3Ctext%20x%3D%27240%27%20y%3D%27270%27%20font-size%3D%2744%27%3E%26%23247%3B%3C%2Ftext%3E%3Ctext%20x%3D%2760%27%20y%3D%27290%27%20font-size%3D%2744%27%3E%25%3C%2Ftext%3E%3Ctext%20x%3D%27260%27%20y%3D%27170%27%20font-size%3D%2740%27%3E%3D%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fsvg%3E"),
        radial-gradient(circle at 50% 0%, #123a24 0%, #060907 65%);
    background-repeat: no-repeat, repeat, no-repeat;
}

body.light-theme .game-container {
    background-color: #114a27;
    background-image: 
        radial-gradient(circle at 50% 12%, rgba(110, 231, 183, 0.3) 0%, transparent 55%),
        radial-gradient(circle at center, #277e4b 0%, #114a27 100%);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.08);
}

@keyframes shakeScreen {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-3px, 3px) rotate(-1deg); }
    50% { transform: translate3d(3px, -2px, 0) rotate(1deg); }
    75% { transform: translate(-2px, -3px) rotate(0deg); }
}
.anim-shake-screen { animation: shakeScreen 0.5s ease-out; }

.selection-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 40; transition: opacity 0.2s ease;
}
.selection-overlay.hidden { display: none; }

.game-header {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.game-header h1 { grid-column: 2; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; color: #ffffff; text-shadow: 0 2px 4px rgba(0,0,0,0.3); margin: 0; text-align: center; }
.header-icons-group { grid-column: 3; display: flex; gap: 6px; justify-content: flex-end; }

.info-btn {
    background: rgba(255, 255, 255, 0.15); color: #f4f4f5; border: 1px solid rgba(255,255,255,0.2); width: 28px; height: 28px;
    border-radius: 50%; font-weight: bold; font-size: 0.85rem; cursor: pointer;
    transition: background 0.2s, transform 0.2s; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.info-btn:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.05); }
.info-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.info-btn:disabled:hover { background: rgba(255, 255, 255, 0.15); transform: none; }

.mode-toggle {
    display: flex; gap: 4px; background: rgba(0,0,0,0.3); border-radius: 20px;
    padding: 4px; margin: 10px 0 2px; border: 1px solid rgba(255,255,255,0.1);
}
.mode-btn {
    flex: 1; background: transparent; border: none; color: #9ca3af; font-weight: 700;
    font-size: 0.75rem; letter-spacing: 0.5px; padding: 8px 0; border-radius: 16px; cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    font-family: 'Baloo 2', 'Quicksand', sans-serif;
}
.mode-btn.active { background: #34d399; color: #063a22; box-shadow: 0 2px 8px rgba(52,211,153,0.4); }

.best-level-badge {
    text-align: center; font-size: 0.75rem; font-weight: 700; color: #fde68a;
    background: rgba(0,0,0,0.3); border: 1px solid rgba(253,230,138,0.25); border-radius: 20px;
    padding: 5px 14px; margin: 6px auto 0; width: fit-content;
    font-family: 'Baloo 2', 'Quicksand', sans-serif;
}

.endless-level-msg {
    text-align: center; color: #93c5fd; font-weight: 700; font-size: 1rem; margin: 8px 0;
    font-family: 'Baloo 2', 'Quicksand', sans-serif;
}

.puzzle-info {
    font-size: 0.75rem; font-weight: 600; color: #d1d5db; background: rgba(0, 0, 0, 0.35);
    padding: 3px 10px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1);
    letter-spacing: 0.5px;
}

.hud-center-stack {
    display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 10px 0;
}

.target-box {
    display: flex; flex-direction: column; align-items: center; 
    background: rgba(251, 191, 36, 0.1);
    backdrop-filter: blur(8px);
    padding: 8px 24px; border-radius: 10px; 
    border: 1px solid rgba(251, 191, 36, 0.4);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25), inset 0 0 12px rgba(251, 191, 36, 0.12);
}
.target-box .label { font-size: 0.65rem; letter-spacing: 1.5px; color: #fde68a; font-weight: 700; }
.target-box .target-val { font-size: 1.4rem; font-weight: 800; color: #ffffff; text-shadow: 0 2px 8px rgba(251, 191, 36, 0.5); }

.current-box {
    display: flex; flex-direction: column; align-items: center; 
    background: rgba(13, 56, 31, 0.85);
    backdrop-filter: blur(12px);
    padding: 14px 34px; border-radius: 16px; 
    border: 2px solid rgba(52, 211, 153, 0.4);
    min-width: 150px; 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(52, 211, 153, 0.2);
}
.label { font-size: 0.75rem; letter-spacing: 1.5px; color: #6ee7b7; font-weight: 700; margin-bottom: 2px; }

.value {
    font-size: 2.3rem; font-weight: 900; color: #ffffff; display: inline-block; position: relative;
    text-shadow: 0 2px 10px rgba(52, 211, 153, 0.5);
    transition: transform 0.1s ease;
}

.anim-add-glow { color: #34d399 !important; transform: scale(1.12); text-shadow: 0 0 15px #34d399 !important; }
.anim-sub-glow { color: #f87171 !important; transform: scale(1.12); text-shadow: 0 0 15px #f87171 !important; }

@keyframes impactBurst {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.55); filter: brightness(1.7); color: #ffffff; text-shadow: 0 0 30px #34d399; }
    100% { transform: scale(1); filter: brightness(1); }
}
.anim-mult { animation: impactBurst 0.7s ease-out; }

@keyframes sliceCut {
    0% { transform: scale(1); opacity: 1; filter: blur(0); }
    30% { transform: scale(1.25) skewX(12deg); opacity: 0.4; filter: blur(3px); color: #60a5fa; }
    50% { transform: scale(0.7); opacity: 0; }
    80% { transform: scale(1.1); opacity: 0.8; filter: blur(0); }
    100% { transform: scale(1); opacity: 1; }
}
.anim-slice { animation: sliceCut 0.8s ease-in-out; }
.anim-slice::after {
    content: ''; position: absolute; top: 50%; left: -30%; width: 160%; height: 4px;
    background: #93c5fd; box-shadow: 0 0 15px #3b82f6; transform: rotate(-25deg) scaleX(0);
    animation: slashLine 0.8s ease-in-out; pointer-events: none;
}
@keyframes slashLine {
    0% { transform: rotate(-25deg) scaleX(0); opacity: 0; }
    25% { transform: rotate(-25deg) scaleX(1); opacity: 1; }
    75% { transform: rotate(-25deg) scaleX(1) translateY(25px); opacity: 0.8; }
    100% { transform: rotate(-25deg) scaleX(0) translateY(35px); opacity: 0; }
}

@keyframes flip3D {
    0% { transform: perspective(500px) rotateY(0deg); }
    50% { transform: perspective(500px) rotateY(180deg) scale(1.3); color: #fbbf24; text-shadow: 0 0 20px #fbbf24; }
    100% { transform: perspective(500px) rotateY(360deg); }
}

@keyframes digitCollapse {
    0% { opacity: 1; transform: scale(1); filter: blur(0); letter-spacing: 2px; }
    35% { opacity: 0.35; transform: scale(0.55); filter: blur(2px); letter-spacing: -3px; color: #fbbf24; text-shadow: 0 0 18px #fbbf24; }
    65% { opacity: 0.8; transform: scale(1.18); filter: blur(0); letter-spacing: 0px; color: #fbbf24; }
    100% { opacity: 1; transform: scale(1); letter-spacing: 0px; }
}
.anim-digisum { animation: digitCollapse 0.7s ease-in-out; }
.anim-reverse { animation: flip3D 0.8s ease-in-out; }

@keyframes goldPulseInPlace {
    0% { transform: var(--base-transform) translateY(0) scale(1); filter: brightness(1); box-shadow: -4px 8px 20px rgba(0, 0, 0, 0.45); border-color: #e4e4e7; }
    50% { transform: var(--base-transform) translateY(-25px) scale(1.12); box-shadow: 0 0 30px rgba(251, 191, 36, 0.9); border-color: #fbbf24; background-color: #fffbeb; filter: brightness(1.2); }
    100% { transform: var(--base-transform) translateY(0) scale(1); filter: brightness(1); box-shadow: -4px 8px 20px rgba(0, 0, 0, 0.45); border-color: #e4e4e7; }
}
.anim-pulse-local { animation: goldPulseInPlace 0.8s ease-in-out; z-index: 70 !important; }

@keyframes goldPulseSimple {
    0% { text-shadow: 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
    50% { text-shadow: 0 0 35px rgba(251, 191, 36, 1); color: #fbbf24; transform: scale(1.25); }
    100% { text-shadow: 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
}
.anim-pulse { animation: goldPulseSimple 0.7s ease-out; }

@keyframes errorShake {
    0%, 100% { transform: translateX(0); color: #fff; }
    20%, 60% { transform: translateX(-8px); color: #f87171; }
    40%, 80% { transform: translateX(8px); color: #f87171; }
}
.anim-error { animation: errorShake 0.4s ease; }

.control-bar-symbols { display: flex; gap: 8px; margin-top: 4px; }

.symbol-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff; 
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 8px 12px; 
    font-weight: 700; 
    font-size: 0.85rem; 
    border-radius: 10px; 
    cursor: pointer;
    transition: all 0.2s ease; 
    display: flex; 
    align-items: center; 
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.symbol-btn:hover { 
    background: rgba(255, 255, 255, 0.25); 
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}
.symbol-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.symbol-btn.ad-hint-active {
    background: linear-gradient(135deg, #f97316, #ea580c);
    border-color: rgba(255, 200, 150, 0.5);
    animation: adHintGlow 1.8s ease-in-out infinite;
}
@keyframes adHintGlow {
    0%, 100% { box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4); }
    50% { box-shadow: 0 4px 22px rgba(249, 115, 22, 0.85); }
}

.proximity-track {
    width: 100%; height: 5px; margin-top: 8px; border-radius: 4px;
    background: rgba(0, 0, 0, 0.35); overflow: hidden; border: 1px solid rgba(255,255,255,0.08);
}
.proximity-fill {
    height: 100%; width: 0%; border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.4s ease;
    background-color: #ef4444;
}
.proximity-fill.prox-cold { background-color: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
.proximity-fill.prox-warm { background-color: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }
.proximity-fill.prox-hot { background-color: #34d399; box-shadow: 0 0 10px rgba(52, 211, 153, 0.7); }

.par-indicator {
    display: flex; align-items: center; gap: 6px; font-size: 0.7rem; letter-spacing: 0.5px;
    color: #d1d5db; background: rgba(0, 0, 0, 0.3); padding: 4px 12px; border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1); font-weight: 600;
}
.par-indicator strong { font-size: 0.75rem; }
.par-divider { color: rgba(255,255,255,0.3); }
.par-indicator.par-under strong#moves-value { color: #34d399; }
.par-indicator.par-even strong#moves-value { color: #fbbf24; }
.par-indicator.par-over strong#moves-value { color: #f87171; }

.star-rating {
    font-size: 1.5rem; letter-spacing: 4px; text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    animation: starPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes starPop { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }

.confetti-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 300; overflow: hidden;
}
.confetti-piece {
    position: absolute; top: 45%; left: 50%; width: 8px; height: 14px;
    opacity: 1; border-radius: 2px;
    animation-name: confettiBurst;
    animation-timing-function: cubic-bezier(0.25, 0.8, 0.4, 1);
    animation-fill-mode: forwards;
}
@keyframes confettiBurst {
    0% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) rotate(var(--rot)); opacity: 0; }
}

.stuck-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; margin-left: 6px; border-radius: 50%;
    background: rgba(107, 114, 128, 0.4); color: #e5e7eb; font-size: 0.6rem; font-weight: 800;
    border: 1px solid rgba(255,255,255,0.2); cursor: help;
    animation: stuckPulse 1.8s ease-in-out infinite;
}
.stuck-badge.hidden { display: none; }
@keyframes stuckPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.legal-footer {
    text-align: center; padding: 8px 0 4px; font-size: 0.7rem;
}
.legal-footer a { color: #6b7280; text-decoration: none; }
.legal-footer a:hover { color: #a7f3d0; text-decoration: underline; }
.legal-footer span { color: #4b5563; margin: 0 6px; }

.proximity-fill.prox-stuck {
    background-color: #6b7280 !important;
    box-shadow: none !important;
    opacity: 0.55;
}

.card-hand-wrapper {
    position: relative; height: 220px; width: 100%; display: flex; justify-content: center; align-items: flex-end;
}
.card-tray { position: relative; width: 100%; height: 155px; display: flex; justify-content: center; }

/* Integrated Win Board Panel */
.win-screen-panel {
    position: absolute;
    bottom: 10px;
    width: 95%;
    background: rgba(13, 56, 31, 0.92);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(52, 211, 153, 0.5);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(52, 211, 153, 0.2);
    z-index: 80;
    animation: winPanelPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.win-screen-panel.hidden { display: none; opacity: 0; transform: translateY(20px); pointer-events: none; }
@keyframes winPanelPop {
    0% { transform: scale(0.85) translateY(15px); opacity: 0; }
    60% { transform: scale(1.03) translateY(0); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}
.win-screen-panel h2 { font-size: 1.2rem; color: #ffffff; text-shadow: 0 2px 5px rgba(0,0,0,0.4); }
.win-screen-panel p { font-size: 0.85rem; color: #a7f3d0; margin-bottom: 2px; }

.win-stats-row {
    display: flex; justify-content: space-around; background: rgba(0, 0, 0, 0.35); padding: 8px; border-radius: 8px; font-size: 0.85rem; color: #d1d5db;
    border: 1px solid rgba(255,255,255,0.08);
}

.timer-box-integrated {
    display: flex; flex-direction: column; align-items: center; background: rgba(255, 255, 255, 0.06); padding: 6px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
}
.timer-box-integrated .label { font-size: 0.6rem; letter-spacing: 1.2px; color: #6ee7b7; margin-bottom: 1px; }
.timer-val { font-size: 1.1rem; font-weight: 800; color: #ffffff; font-variant-numeric: tabular-nums; }

.archive-encourage-btn {
    display: block; width: 100%; margin-top: 8px; padding: 8px; background: rgba(96, 165, 250, 0.12);
    border: 1px dashed rgba(96, 165, 250, 0.45); border-radius: 10px; color: #93c5fd;
    font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 0.78rem; cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}
.archive-encourage-btn:hover { background: rgba(96, 165, 250, 0.22); }
.archive-encourage-btn:active { transform: scale(0.98); }

.win-actions-row { display: flex; gap: 8px; }

.round-solved-flash {
    animation: roundSolvedFlash 0.6s ease-out;
}
@keyframes roundSolvedFlash {
    0% { box-shadow: 0 0 0 rgba(52, 211, 153, 0); }
    35% { box-shadow: 0 0 35px rgba(52, 211, 153, 0.9); border-color: #34d399; }
    100% { box-shadow: 0 0 0 rgba(52, 211, 153, 0); }
}

.number-scramble {
    animation: numberScramble 0.1s linear infinite;
}
@keyframes numberScramble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.run-summary-panel {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(139, 92, 246, 0.15);
}

.out-of-cards-panel {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(239, 68, 68, 0.15);
}
.out-of-cards-panel p { color: #fca5a5; }

.solution-reveal-box {
    background: rgba(139, 92, 246, 0.12); border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 10px; padding: 10px; font-size: 0.8rem; color: #ddd6fe; line-height: 1.5;
    text-align: left;
}
.solution-reveal-box strong { color: #c4b5fd; }

.card {
    position: absolute; width: 90px; height: 130px; background-color: #ffffff; border: 3px solid var(--accent, #e4e4e7);
    border-radius: 12px; display: flex; flex-direction: column; justify-content: space-between; padding: 8px;
    color: #18181b; cursor: pointer; box-shadow: -4px 8px 20px rgba(0, 0, 0, 0.45); user-select: none;
    transform-origin: bottom center; transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
    touch-action: none;
}

.card.dealing {
    animation: dealCardIn 0.45s cubic-bezier(0.19, 1, 0.22, 1) both;
}
@keyframes dealCardIn {
    0% { opacity: 0; transform: translateY(160px) scale(0.75) rotate(0deg); }
    100% { opacity: 1; transform: var(--base-transform); }
}

.card.dragging {
    transition: transform 0s, box-shadow 0.25s ease;
    cursor: grabbing;
    box-shadow: 0 42px 60px rgba(0, 0, 0, 0.7), 0 10px 18px rgba(0, 0, 0, 0.45);
}
.card.drop-ready {
    box-shadow: 0 0 25px 6px rgba(52, 211, 153, 0.85) !important;
    border-color: #34d399 !important;
}

.current-box {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.current-box.drag-hover {
    border-color: #34d399;
    box-shadow: 0 0 30px rgba(52, 211, 153, 0.6), inset 0 0 20px rgba(52, 211, 153, 0.25);
    transform: scale(1.05);
}

.card-top-row { display: flex; justify-content: space-between; align-items: flex-start; width: 100%; }
.card .corner-tl {
    font-size: 0.75rem; font-weight: 800; line-height: 1; text-align: center;
    background: var(--accent, #9ca3af); color: #ffffff; border-radius: 6px; padding: 3px 6px; min-width: 20px;
}
.card .corner-br {
    font-size: 0.75rem; font-weight: 800; line-height: 1; text-align: center; align-self: flex-end; transform: rotate(180deg);
    background: var(--accent, #9ca3af); color: #ffffff; border-radius: 6px; padding: 3px 6px; min-width: 20px;
}

.card-help-btn {
    background: rgba(0,0,0,0.08); border: none; color: #52525b; width: 18px; height: 18px; border-radius: 50%;
    font-size: 0.7rem; font-weight: bold; cursor: pointer; display: none; align-items: center; justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.card-help-btn:hover { background: #3b82f6; color: #fff; }
.card.selected .card-help-btn { display: flex; }

.card .center-val { align-self: center; justify-self: center; font-size: 1.6rem; font-weight: 900; letter-spacing: -0.5px; }
.card.special-card .center-val { font-size: 1.05rem; color: #d97706; font-weight: 800; }
.card.special-card { color: #d97706; }

.card.selected {
    transform: translateY(-95px) scale(1.3) rotate(0deg) !important; z-index: 55 !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.75); border-color: #3b82f6;
}

.card.disabled-pointer { pointer-events: none !important; }

.card-actions-container {
    position: absolute; bottom: -36px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 60; white-space: nowrap;
    touch-action: manipulation;
}

.action-btn {
    padding: 6px 12px; font-weight: 800; font-size: 0.75rem; border-radius: 6px; border: none; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: transform 0.15s ease;
    touch-action: manipulation;
}
.action-btn:hover { transform: scale(1.05); }
.use-btn { background-color: #10b981; color: white; }
.cancel-btn { background-color: #ef4444; color: white; }

.card.used { opacity: 0.25; pointer-events: none; transform: translateY(10px) rotate(0deg) !important; }

.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.75); backdrop-filter: blur(6px);
    display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 1; transition: opacity 0.2s ease;
}
.modal.hidden { display: none; opacity: 0; pointer-events: none; }

.modal-content {
    background: radial-gradient(circle at center, #165330 0%, #0c311c 100%);
    border: 2px solid rgba(52, 211, 153, 0.4);
    padding: 24px;
    border-radius: 16px;
    width: 85%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(52, 211, 153, 0.15);
    color: #f4f4f5;
    position: relative;
}
.modal-content h2 { font-size: 1.25rem; color: #ffffff; margin-bottom: 8px; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.modal-content p { font-size: 0.9rem; color: #a7f3d0; margin-bottom: 10px; }

.tutorial-modal-content { padding-top: 30px; }

.glossary-modal-content { max-height: 80vh; display: flex; flex-direction: column; }
.glossary-list { overflow-y: auto; max-height: 55vh; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-right: 4px; }
.glossary-item {
    display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.05);
    border-radius: 10px; padding: 8px 10px; border-left: 4px solid var(--accent, #9ca3af);
}
.glossary-item .glossary-badge {
    flex-shrink: 0; min-width: 44px; text-align: center; font-weight: 800; font-size: 0.8rem;
    background: var(--accent, #9ca3af); color: #fff; border-radius: 6px; padding: 4px 6px;
    font-family: 'Baloo 2', sans-serif;
}
.glossary-item .glossary-desc { font-size: 0.78rem; color: #d1d5db; line-height: 1.35; }
.tutorial-icon { font-size: 2.6rem; margin-bottom: 8px; animation: iconPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes iconPop { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
.tutorial-modal-content p { font-size: 0.88rem; line-height: 1.5; min-height: 62px; }
.tutorial-demo {
    position: relative; height: 90px; margin: 10px 0 4px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.25); border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
}
.demo-number-box {
    display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 2;
}
.demo-label { font-size: 0.6rem; letter-spacing: 1px; color: #a7f3d0; font-weight: 700; }
.demo-num-stack { position: relative; width: 34px; height: 34px; }
.demo-num {
    position: absolute; inset: 0; font-family: 'Baloo 2', sans-serif; font-size: 1.6rem;
    font-weight: 800; color: #ffffff; text-align: center;
}
.demo-num-before { animation: demoNumBeforeFade 2.6s ease-in-out infinite; }
.demo-num-after { animation: demoNumAfterFade 2.6s ease-in-out infinite; opacity: 0; }
@keyframes demoNumBeforeFade { 0%, 42% { opacity: 1; } 52%, 100% { opacity: 0; } }
@keyframes demoNumAfterFade { 0%, 42% { opacity: 0; } 52%, 100% { opacity: 1; transform: scale(1.15); } 70%, 100% { transform: scale(1); } }
.demo-card {
    position: absolute; width: 46px; height: 62px; background: #ffffff; color: #18181b;
    border: 2px solid #009E73; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 0.95rem;
    animation: demoCardSlide 2.6s ease-in-out infinite;
    box-shadow: 0 6px 14px rgba(0,0,0,0.4);
}
@keyframes demoCardSlide {
    0% { transform: translate(75px, 8px) rotate(8deg) scale(0.85); opacity: 0; }
    15% { transform: translate(75px, 8px) rotate(8deg) scale(0.85); opacity: 1; }
    42% { transform: translate(0, -34px) rotate(0deg) scale(1.05); opacity: 1; }
    55% { transform: translate(0, -34px) rotate(0deg) scale(1.05); opacity: 0; }
    100% { transform: translate(75px, 8px) rotate(8deg) scale(0.85); opacity: 0; }
}

.tutorial-dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0 16px; }
.tutorial-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.25);
    transition: background 0.2s ease, transform 0.2s ease;
}
.tutorial-dots span.active { background: #34d399; transform: scale(1.3); }
.tutorial-actions { display: flex; align-items: center; gap: 10px; }
.tutorial-skip-btn {
    background: none; border: none; color: #9ca3af; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; padding: 10px; font-family: 'Quicksand', sans-serif;
}
.tutorial-skip-btn:hover { color: #d1d5db; }
.tutorial-actions .ctrl-btn { flex: 1; }

.modal-close-x {
    position: absolute; top: 12px; right: 14px;
    background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff; width: 28px; height: 28px; border-radius: 50%;
    font-weight: bold; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.2s;
}
.modal-close-x:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.05); }

.ctrl-btn {
    width: 100%; background-color: #10b981; color: white; border: 1px solid rgba(255, 255, 255, 0.2); padding: 12px;
    font-weight: 700; font-size: 0.85rem; border-radius: 10px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: background 0.2s ease, transform 0.1s ease;
}
.ctrl-btn:hover { background-color: #059669; transform: translateY(-1px); }

.toast {
    position: absolute; top: 80px; left: 50%; transform: translateX(-50%); background-color: #27272a; color: white; padding: 10px 20px;
    border-radius: 8px; font-weight: 700; font-size: 0.9rem; z-index: 2000; opacity: 1; transition: opacity 0.3s ease; pointer-events: none;
    white-space: nowrap; box-shadow: 0 6px 16px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15);
}
.toast.hidden { opacity: 0; }

.custom-calendar {
    background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 12px; margin-bottom: 12px; color: #f4f4f5; user-select: none;
}
.cal-header { font-size: 1rem; font-weight: 600; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); color: #a7f3d0; }
.archive-hint { text-align: center; font-size: 0.75rem; color: #9ca3af; margin: 14px 0 2px; }
.cal-month-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: bold; font-size: 0.95rem; background: rgba(0,0,0,0.2); padding: 6px 10px; border-radius: 8px; }
.cal-arrow-btn { background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.2); color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; transition: background 0.2s; }
.cal-arrow-btn:hover { background: rgba(255, 255, 255, 0.3); }

.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.8rem; color: #9ca3af; margin-bottom: 6px; font-weight: 600; }
.cal-days-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; border-radius: 50%; cursor: pointer; transition: background 0.2s, color 0.2s; color: #e5e7eb; position: relative; }
.cal-day:hover:not(.disabled):not(.other-month) { background: rgba(52, 211, 153, 0.3); }
.cal-day.selected { background: #f97316; color: #fff; font-weight: bold; box-shadow: 0 0 10px rgba(249, 115, 22, 0.6); }
.cal-day.other-month { color: rgba(255,255,255,0.2); cursor: default; }
.cal-day.disabled { color: rgba(255,255,255,0.2); cursor: not-allowed; }
.cal-day.solved:not(.selected) { background: rgba(52, 211, 153, 0.18); color: #6ee7b7; font-weight: 700; }
.cal-day.solved::after {
    content: '✓'; position: absolute; bottom: -2px; right: 0px; font-size: 0.55rem; font-weight: 900;
    color: #34d399; background: #0d381f; border-radius: 50%; width: 12px; height: 12px;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.cal-day.selected.solved::after { color: #f97316; }
/* Force-portrait via CSS rotation. The Screen Orientation Lock API only
   works for an installed PWA on Android Chrome — iOS Safari doesn't support
   it at all, even added-to-home-screen. This CSS trick works universally,
   in any browser, installed or not: when a mobile-sized viewport reports
   landscape, we rotate the whole page back to visual portrait rather than
   letting it reflow. The max-height threshold is what keeps this from ever
   firing on an actual desktop browser window, which is landscape-shaped but
   never this short. */
@media screen and (orientation: landscape) and (max-height: 500px) {
    html {
        transform: rotate(-90deg);
        transform-origin: left top;
        width: 100vh;
        height: 100vw;
        overflow-x: hidden;
        position: absolute;
        top: 100%;
        left: 0;
    }
}

.cookie-consent-banner {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 5000;
    background: rgba(10, 25, 17, 0.97); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(52, 211, 153, 0.35);
    padding: 14px 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
}
.cookie-consent-banner p {
    font-size: 0.78rem; color: #d1d5db; line-height: 1.4; margin: 0; max-width: 480px;
}
.cookie-consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-consent-actions .ctrl-btn { padding: 8px 20px; font-size: 0.8rem; }
.cookie-consent-banner.hidden { display: none; }
