:root {
    --cell-size: clamp(38px, min(14vw, 7.5vh), 70px);
    --gap: clamp(2px, 0.5vmin, 4px);
    --highlight: #e65b27;
    --success: #27ae60;
    --bg-color: #1a1a1a;
    --text-color: white;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Open Sans', 'Segoe UI', Tahoma, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0; margin: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    
    /* NEW: Prevents the zoom animation from triggering a horizontal scrollbar! */
    overflow-x: hidden; 
}

/* --- HEADER SECTION --- */
#score-container {
    /* Massively bumped up the font size to fill the header space */
    font-size: clamp(40px, 8vh, 65px); 
    font-weight: 800; 
    color: var(--highlight);
    
    /* Forces the text to be uppercase and stretches it wider */
    text-transform: uppercase;
    letter-spacing: 2px; 
    
    margin-top: 0px; margin-bottom: 2px;
    cursor: pointer; transition: transform 0.1s;

    /* Perfectly centers the text horizontally and vertically */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px; 
}

#score-container:active { transform: scale(0.95); }

#score {
    /* NEW: Forces all numbers to be exactly the same width so the container never shifts */
    font-variant-numeric: tabular-nums; 

    font-size: inherit;
    font-weight: inherit;
    display: inline-flex;
    height: 1em; 
    line-height: 1;
}

/* The default leading zero for the main score at the top */
.leading-zero {
    opacity: 0.25; 
}

/* NEW: Overrides the opacity ONLY for the Scootches and Letters */
#stats-bar .leading-zero {
    opacity: 0.10; /* Adjust this to make the stats zeros as faint as you want! */
}

.odometer-digit {
    display: flex;
    flex-direction: column;
    height: 1em;
    overflow: hidden;
}

.odometer-track {
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.odometer-track span {
    height: 1em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Make sure you still have the keyframes from before! */
@keyframes flip-axis {
    0% { transform: perspective(400px) rotateX(0deg); opacity: 1; }
    50% { transform: perspective(400px) rotateX(90deg); opacity: 0; }
    100% { transform: perspective(400px) rotateX(0deg); opacity: 1; }
}

#stats-bar {
    display: flex; gap: 20px; margin-bottom: 2px;
    font-size: clamp(12px, 2vh, 18px); color: #aaa; font-weight: 600;
}

/* NEW: Swapped center for baseline so the text bottoms naturally align */
.stat-box { display: flex; align-items: baseline; gap: 4px; }

#moves, #letters-left { 
    color: white; 
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    height: 1em;
    line-height: 1;
    /* (The transform line is completely gone!) */
}

/* .low-moves { color: #e74c3c !important; }

/* FIX: Ensure the red 'low moves' warning overrides light mode colors */
/* body.light-mode #moves.low-moves { color: #e74c3c !important; }

/* --- GAME GRID LAYOUT --- */
.game-layout { display: flex; align-items: center; gap: var(--gap); }
.col-arrows-container { display: flex; justify-content: center; width: 100%; }
.col-arrows-row, .side-arrows { display: grid; gap: var(--gap); }
.col-arrows-row { grid-template-columns: repeat(5, var(--cell-size)); }
.side-arrows { grid-template-rows: repeat(5, var(--cell-size)); }

.grid-container { display: grid; grid-template-rows: repeat(5, var(--cell-size)); gap: var(--gap); overflow: hidden; padding: 0; }
.grid-row { display: flex; gap: var(--gap); height: var(--cell-size); }

/* --- CELLS --- */
.grid-cell { 
    position: relative; width: var(--cell-size); height: var(--cell-size); 
    display: flex; justify-content: center; align-items: center; 
    font-size: calc(var(--cell-size) * 0.55); font-weight: 800; line-height: 1; 
    background-color: var(--bg-color); 
    border-radius: 6px; border: 2px solid transparent; box-sizing: border-box; 
    
    /* NEW: Added border-color and box-shadow to smooth out the highlight removal */
    transition: background-color 0.1s, color 0.1s, border-color 0.3s, box-shadow 0.3s;
    
    cursor: pointer; z-index: 1; 
}
.grid-cell.empty-cell { border: none !important; background: transparent !important; cursor: default !important; box-shadow: none !important; }
.grid-cell > * { pointer-events: none; }

.letter-value { 
    position: absolute; top: 6%; right: 8%; 
    font-size: 0.35em; font-weight: 600; color: #999; line-height: 1; 
}

.grid-cell.selected { background-color: rgba(230, 91, 39, 0.3) !important; border: 2px solid var(--highlight); color: var(--highlight); }
.grid-cell.selected .letter-value { color: var(--highlight); }

/* --- PURE CSS HIGHLIGHT FADE IN ANIMATIONS --- */
@keyframes highlightFadeIn {
    0% { border-color: transparent; box-shadow: inset 0 0 0px rgba(46, 204, 113, 0); }
    100% { border-color: rgba(46, 204, 113, 0.6); box-shadow: inset 0 0 5px rgba(46, 204, 113, 0.15); }
}
@keyframes highlightThickFadeIn {
    0% { border-color: transparent; box-shadow: inset 0 0 0px rgba(46, 204, 113, 0); }
    100% { border-color: #2ecc71; box-shadow: inset 0 0 12px rgba(46, 204, 113, 0.6); }
}

/* CORRECTED VISUAL INTENSITY: Thin is 1px transparent, Thick is 1.5px solid */
.grid-cell.auto-highlight { 
    border: 1px solid rgba(46, 204, 113, 0.6); 
    box-shadow: inset 0 0 5px rgba(46, 204, 113, 0.15); 
    animation: highlightFadeIn 1s ease-out; 
}
.grid-cell.auto-highlight-thick { 
    border: 1.5px solid #2ecc71; 
    box-shadow: inset 0 0 12px rgba(46, 204, 113, 0.6); 
    animation: highlightThickFadeIn 1s ease-out; 
}

.grid-cell.auto-highlight.drop-in {
    animation: dropIn 0.8s cubic-bezier(0.25, 1, 0.5, 1) backwards, highlightFadeIn 0.6s ease-out;
}
.grid-cell.auto-highlight-thick.drop-in {
    animation: dropIn 0.8s cubic-bezier(0.25, 1, 0.5, 1) backwards, highlightThickFadeIn 0.6s ease-out;
}

/* --- ARROWS & CARETS --- */
.arrow { 
    width: var(--cell-size); height: var(--cell-size); 
    font-size: var(--cell-size); background: transparent; 
    border: none; cursor: pointer; padding: 0; 
    display: flex; justify-content: center; align-items: center; 
    color: #666; transition: color 0.2s; 
    -webkit-tap-highlight-color: transparent; 
}
.arrow:hover { color: var(--highlight); }
.arrow.disabled { opacity: 0.2; cursor: default; pointer-events: none; }

.caret { 
    display: inline-block; width: 0.25em; height: 0.25em; 
    border-style: solid; border-color: currentColor; 
    border-width: 0.05em 0.05em 0 0; border-radius: 1px; 
    transition: transform 0.2s; margin-bottom: 0.05em; 
}
.caret-up { transform: rotate(-45deg); margin-top: 0.1em; }
.caret-right { transform: rotate(45deg); margin-left: -0.1em; }
.caret-down { transform: rotate(135deg); margin-bottom: 0.1em; }
.caret-left { transform: rotate(-135deg); margin-right: -0.1em; }
.spacer { width: var(--cell-size); }

/* --- ANIMATIONS --- */
.slide-up { transform: translateY(calc(-1 * (var(--cell-size) + var(--gap)))); transition: transform 0.3s ease-in-out; z-index: 100; }
.slide-down { transform: translateY(calc(var(--cell-size) + var(--gap))); transition: transform 0.3s ease-in-out; z-index: 100; }
.slide-left { transform: translateX(calc(-1 * (var(--cell-size) + var(--gap)))); transition: transform 0.3s ease-in-out; }
.slide-right { transform: translateX(calc(var(--cell-size) + var(--gap))); transition: transform 0.3s ease-in-out; }

@keyframes dropIn { 0% { transform: translateY(-100vh); opacity: 0; } 60% { transform: translateY(10px); opacity: 1; } 100% { transform: translateY(0); opacity: 1; } }
.drop-in { animation: dropIn 0.8s cubic-bezier(0.25, 1, 0.5, 1) backwards; }

/* --- CONTROLS & PREVIEW --- */
#word-preview-container {
    margin-top: 2px; 
    margin-bottom: 14px; 
    height: clamp(24px, 4vh, 32px);
    font-size: clamp(18px, 3.5vh, 32px); font-weight: 700; color: white; 
    text-align: center; display: flex; align-items: center; justify-content: center;
    position: relative; 
}
#preview-text { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.preview-score { color: #888; font-size: 0.65em; margin-left: 4px; transform: translateY(1px); }

/* --- NEW COMBO UI CLASSES --- */
.combo-indicator {
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--success); /* <--- CHANGED TO SUCCESS (GREEN) */
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    white-space: nowrap;
}
.combo-primary { 
    color: var(--success) !important;  /* <--- CHANGED TO SUCCESS (GREEN) */
}

.controls { margin-top: 5px; display: flex; gap: 10px; padding-bottom: 5px; }
.main-btn { 
    padding: 10px 15px; 
    font-size: clamp(14px, 2.5vh, 18px); 
    font-weight: 700; 
    border-radius: 8px; 
    border: none; 
    cursor: pointer; 
    
    /* ADD THESE TWO LINES: Gives unstyled buttons a safe dark default */
    background: #555; 
    color: #ffffff; 
}
#submit-btn { background: #27ae60; color: white; }
#clear-btn { background: #c0392b; color: white; }
.main-btn:disabled { opacity: 0.5; cursor: default; }

/* --- FOOTER --- */
.footer-menu { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 20px; padding-bottom: 10px; row-gap: 5px; column-gap: 15px; }
.footer-link { background: none; border: none; color: #888; cursor: pointer; font-size: clamp(11px, 1.5vh, 14px); font-weight: 600; text-transform: uppercase; font-family: inherit; transition: color 0.2s; }
.footer-link:hover { color: var(--highlight); }
.copyright { 
    width: max-content; 
    margin: 5px auto 0 auto; 
    text-align: center; 
    color: #444; 
    font-size: 13px; 
    letter-spacing: 0.5px; 
    
    /* NEW: Makes it feel like a button! */
    cursor: pointer;
    transition: color 0.2s;
}

.copyright:hover {
    color: var(--highlight);
}

/* --- MODALS --- */
.hidden { display: none !important; }
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; }
.modal-content { 
    background: #222; 
    padding: 30px; 
    border-radius: 12px; 
    text-align: center; 
    border: 2px solid var(--highlight); 
    width: 85%; 
    max-width: 450px; 
    position: relative; 
    box-sizing: border-box; 
    max-height: 85vh; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    /* The overflow-x line is completely gone! */
}
.modal-content.text-left { text-align: left; }
.modal-content h2 { margin-top: 0; color: var(--highlight); font-size: 28px; font-weight: 800; margin-bottom: 15px; text-transform: uppercase; }
.modal-content p { color: #aaa; font-size: 18px; margin-bottom: 5px; }
#start-logo { width: 100%; max-width: 450px; margin-bottom: 30px; display: block; margin-left: auto; margin-right: auto; }
.start-content { 
    background: transparent !important; 
    border: none !important; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    
    /* NEW: Kills modal scrollbars and lets the logo pop out safely! */
    overflow: visible !important; 
}

.close-x { position: absolute; top: 15px; right: 15px; font-size: 32px; color: #666; cursor: pointer; font-weight: 700; line-height: 1; transition: color 0.2s; }
.close-x:hover { color: var(--highlight); }

#final-score-display { 
    font-size: 64px; 
    font-weight: 800; 
    color: white; 
    line-height: 1; 
    
    /* Pulled up closer to GAME OVER, and reduced bottom gap */
    margin-top: -20px; 
    margin-bottom: 10px; 
}
.initials-container { display: flex; justify-content: center; gap: 15px; margin: 20px 0; }
.initial-box-group { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.initial-box { width: 50px; height: 60px; background: #111; border: 2px solid #444; color: white; font-size: 32px; font-weight: 700; display: flex; justify-content: center; align-items: center; border-radius: 4px; }
.arrow-btn { background: none; border: none; color: var(--highlight); font-size: 18px; cursor: pointer; padding: 5px; transition: transform 0.1s; }
.arrow-btn:active { transform: scale(0.9); }

.history-content { max-height: 80vh; display: flex; flex-direction: column; }
#history-list { flex: 1; overflow-y: auto; margin-top: 10px; border-top: 1px solid #444; border-bottom: 1px solid #444; text-align: left; max-height: 300px; }
.history-item { display: flex; justify-content: space-between; padding: 12px 10px; border-bottom: 1px solid #333; font-size: 20px; color: white; }
.history-points { color: var(--success); font-weight: 700; }

/* --- HALL OF FAME TABS --- */
.score-tabs { 
    display: flex; 
    justify-content: center; 
    gap: 4px; /* Reduced the gap from 5px to 4px */
    margin-bottom: 15px; 
    flex-wrap: wrap; 
}
.tab-btn { 
    background: transparent; 
    border: 1px solid #444; 
    color: #888; 
    padding: 8px 4px; /* Shaved 2px off the sides to make room for the larger font */
    cursor: pointer; 
    font-size: 12px; /* Bumped back up! */
    font-weight: 700; 
    text-transform: uppercase; 
    transition: all 0.2s; 
}
.tab-btn:hover { border-color: var(--highlight); color: white; }
.tab-btn.active { background: var(--highlight); color: white; border-color: var(--highlight); }
.high-score-header { display: grid; grid-template-columns: 0.5fr 1fr 1fr 1fr; font-weight: 700; color: #888; border-bottom: 2px solid #444; padding-bottom: 10px; margin-bottom: 10px; font-size: 14px; }
.high-score-row { display: grid; grid-template-columns: 0.5fr 1fr 1fr 1fr; padding: 8px 0; border-bottom: 1px solid #333; color: white; font-size: 16px; align-items: center;}
.high-score-row:last-child { border-bottom: none; }
.high-score-rank { color: var(--highlight); font-weight: bold; }
.word-col { font-family: monospace; letter-spacing: 1px; color: var(--success); }

/* --- GAME OVER WORD BREAKDOWN --- */
.word-breakdown-container {
    text-align: left; 
    max-height: 30vh; 
    overflow-y: auto;
    
    /* Reduced top margin to 5px to pull it up closer to the score */
    margin: 5px 0 5px 0;
    
    padding: 15px; 
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid #333;
}

.word-breakdown-group { 
    margin-bottom: 20px; 
}

.word-breakdown-group:last-child { 
    margin-bottom: 0; 
}

.word-breakdown-title { 
    font-weight: 800; 
    color: var(--highlight); 
    margin-bottom: 4px; 
    font-size: 14px; 
    text-transform: uppercase; 
}

.word-breakdown-list { 
    color: #ddd; 
    line-height: 1.6; 
    font-size: 14px; 
}

/* Light mode overrides for the Game Over screen & breakdown */
body.light-mode .word-breakdown-container {
    background: rgba(0,0,0,0.03) !important;
    border-color: #cbd5e1 !important;
}

body.light-mode .word-breakdown-title { 
    color: #27ae60 !important; 
}

body.light-mode .word-breakdown-list { 
    color: #475569 !important; 
}

body.light-mode #final-score-display {
    color: #2c3e50 !important; 
}

/* =========================================
   MIGRATED INDEX.HTML STYLES 
   ========================================= */

.highlight-row {
    background-color: rgba(39, 174, 96, 0.15) !important;
    border-left: 4px solid #27ae60;
    border-radius: 4px;
    animation: highlightFlash 1.5s ease-out;
}
@keyframes highlightFlash {
    0% { background-color: rgba(39, 174, 96, 0.8); }
    100% { background-color: rgba(39, 174, 96, 0.15); }
}

/* Long Press mobile safeguards */
.arrow {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.arrow.disabled {
    pointer-events: auto !important; 
}

/* Exit Button Styling */
#exit-btn {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 15px);
    right: calc(env(safe-area-inset-right, 0px) + 20px);
    background: none;
    border: none;
    color: #666;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 100;
    padding: 0;
    transition: color 0.2s;
}
#exit-btn:hover {
    color: #fff;
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .start-content {
        width: 80% !important; 
        padding-left: 15px !important;
        padding-right: 15px !important;
        /* Deleted the overflow line from here! */
    }
    #start-daily-btn, #start-random-btn, #start-new-random-btn {
        font-size: 15px !important; 
        white-space: nowrap !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
    #exit-btn {
        top: calc(env(safe-area-inset-top, 0px) + 10px);
        right: calc(env(safe-area-inset-right, 0px) + 15px);
        font-size: 32px;
        padding: 5px; 
    }
    
    /* UPDATED LOGO TRICK */
    #start-logo {
        width: 100%; /* Keeps it anchored properly */
        transform: scale(1.25); /* Scales it up 25% perfectly from the center */
        margin-bottom: 25px; 
    }
}

/* Login specific styles */
.pin-input {
    background: rgba(0,0,0,0.3);
    border: 2px solid #555;
    color: white;
    padding: 10px;
    font-size: 24px;
    border-radius: 8px;
    width: 120px;
    text-align: center;
    letter-spacing: 5px;
    margin-top: 15px;
    outline: none;
}
.pin-input:focus {
    border-color: #3498db;
}

.logged-in-user {
    color: #3498db;
    font-weight: bold;
}

/* Settings UI Text */
.settings-label { color: white; }

/* =========================================
   WORD SUB-TABS 
   ========================================= */
.word-sub-tab { cursor: pointer; color: #666; transition: color 0.2s; }
.word-sub-tab:hover { color: #aaa; }
.word-sub-tab.active { color: #3498db; }
.word-sub-divider { color: #444; }
.empty-dash { color: #555; }

/* =========================================
   STATS UI
   ========================================= */
.stat-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}
.stat-card-label { font-size: 11px; color: #888; margin-bottom: 5px; text-align: center; }
.stat-card-value { font-size: 20px; font-weight: bold; color: #ddd; text-align: center; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-row-label { color: #aaa; font-size: 13px; }
.stat-row-value { font-weight: bold; color: #ddd; }
.stat-header { font-size: 14px; font-weight: bold; margin-bottom: 10px; border-bottom: 1px solid #333; padding-bottom: 5px; }

/* =========================================
   BONUS TILE STYLES
   ========================================= */
.bonus-tile {
    /* Only text is purple when not in a word - inherits default border/bg */
    color: #9b59b6 !important; 
}
.bonus-tile.auto-highlight {
    border: 1px solid rgba(155, 89, 182, 0.6) !important;
    color: #9b59b6 !important;
    box-shadow: inset 0 0 5px rgba(155, 89, 182, 0.15) !important;
}
.bonus-tile.auto-highlight-thick {
    border: 1.5px solid #9b59b6 !important;
    color: #9b59b6 !important;
    box-shadow: inset 0 0 12px rgba(155, 89, 182, 0.6) !important;
}

/* =========================================
   LIGHT MODE OVERRIDES 
   ========================================= */
body.light-mode {
    background-color: #f0f4f8 !important;
    color: #2c3e50 !important;
}
body.light-mode .modal-content {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
}

/* Base Light Mode Tile (No outline unless part of a word) */
body.light-mode .grid-cell {
    background-color: #e2e8f0 !important;
    color: #27ae60 !important;
    border: 2px solid transparent !important; 
}
body.light-mode .grid-cell.empty-cell {
    background-color: #cbd5e1 !important;
}
body.light-mode .grid-cell.selected {
    background-color: #f39c12 !important;
    color: #ffffff !important;
    border-color: #e67e22 !important;
}
body.light-mode .grid-cell.auto-highlight {
    border: 1px solid rgba(39, 174, 96, 0.6) !important;
    color: #27ae60 !important;
}
body.light-mode .grid-cell.auto-highlight-thick {
    border: 1.5px solid #27ae60 !important;
    color: #27ae60 !important;
    font-weight: 900 !important;
}

/* Light mode Bonus logic mapping */
body.light-mode .bonus-tile {
    /* Only text is purple when not in a word - inherits default border/bg */
    color: #8e44ad !important; 
}
body.light-mode .bonus-tile.auto-highlight {
    border: 1px solid rgba(142, 68, 173, 0.6) !important;
    color: #8e44ad !important;
}
body.light-mode .bonus-tile.auto-highlight-thick {
    border: 1.5px solid #8e44ad !important;
    color: #8e44ad !important;
    font-weight: 900 !important;
}

body.light-mode .word-sub-tab { color: #94a3b8; }
body.light-mode .word-sub-tab:hover { color: #64748b; }
body.light-mode .word-sub-tab.active { color: #3498db; }
body.light-mode .word-sub-divider { color: #cbd5e1; }
body.light-mode .empty-dash { color: #94a3b8; }
body.light-mode #word-sub-tabs { border-top-color: #cbd5e1 !important; }

body.light-mode .stat-card {
    background: rgba(0,0,0,0.03) !important;
    border-color: #cbd5e1 !important;
}
body.light-mode .stat-card-value, body.light-mode .stat-row-value { color: #2c3e50 !important; }
body.light-mode .stat-card-label { color: #64748b !important; }
body.light-mode .stat-row-label { color: #475569 !important; }
body.light-mode .stat-header { border-bottom-color: #cbd5e1 !important; }

body.light-mode .stat-box, 
body.light-mode #score-container,
body.light-mode #moves,
body.light-mode #letters-left,
body.light-mode #score,
body.light-mode #word-preview-container,
body.light-mode #preview-text {
    color: #2c3e50 !important;
}

body.light-mode .footer-link {
    color: #64748b !important;
}
body.light-mode .footer-link:hover {
    color: #2c3e50 !important;
}
body.light-mode .copyright, body.light-mode .close-x {
    color: #94a3b8 !important;
}
body.light-mode .tab-btn {
    background: #e2e8f0 !important;
    color: #64748b !important;
}
body.light-mode .tab-btn.active {
    background: #3498db !important;
    color: #ffffff !important;
}
body.light-mode .high-score-header {
    border-bottom: 2px solid #cbd5e1 !important;
    color: #64748b !important;
}
body.light-mode .high-score-row, body.light-mode .history-item {
    border-bottom: 1px solid #e2e8f0 !important;
    color: #2c3e50 !important;
}
body.light-mode .pin-input, body.light-mode .initial-box {
    background: #f8fafc !important;
    border: 2px solid #cbd5e1 !important;
    color: #2c3e50 !important;
}
body.light-mode .arrow-btn, body.light-mode .caret, body.light-mode #exit-btn {
    color: #64748b !important;
    border-color: #64748b !important;
}
body.light-mode #exit-btn:hover {
    color: #2c3e50 !important;
}
body.light-mode .settings-label {
    color: #2c3e50 !important;
}

body.light-mode .combo-indicator,
body.light-mode .combo-primary {
    color: #27ae60 !important;
}

body.light-mode .modal-content [style*="color: #ddd"], 
body.light-mode .modal-content [style*="color: #aaa"] {
    color: #475569 !important;
}
body.light-mode .modal-content div[style*="background: rgba(255,255,255,0.05)"] {
    background: rgba(0,0,0,0.03) !important;
    border-color: #cbd5e1 !important;
}

/* --- BADGE UI STYLES --- */
.badge-section {
    margin-top: 25px;
    border-top: 2px solid #333;
    padding-top: 15px;
}
.badge-info-box {
    background: #1a252f;
    border: 1px solid #34495e;
    border-radius: 8px;
    padding: 10px;
    min-height: 50px;
    text-align: center;
    margin-bottom: 15px;
    color: #bdc3c7;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.badge-info-title {
    color: #f39c12;
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 3px;
}
.badge-locked {
    background: #1e2b38 !important;
    filter: grayscale(100%);
    opacity: 0.4;
    box-shadow: none !important;
}
.badge-locked .badge-name-mini {
    color: #7f8c8d;
}

/* UPDATED FOR MOBILE */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 6px; 
    justify-content: center;
}
.badge-item {
    background: #2c3e50;
    border-radius: 10px;
    padding: 8px 2px; 
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.1s;
    user-select: none;
}
.badge-item:active {
    transform: scale(0.92);
}
.badge-icon {
    font-size: 28px; 
    margin-bottom: 4px;
    line-height: 1;
}
.badge-name-mini {
    font-size: 9px;
    color: #fff;
    line-height: 1.15;
    white-space: normal; 
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- GAME OVER WORD BREAKDOWN --- */
.word-breakdown-container {
    text-align: left; 
    max-height: 30vh; 
    overflow-y: auto;
    margin: 15px 0 5px 0;
    padding: 15px; 
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid #333;
}

.word-breakdown-group { 
    margin-bottom: 20px; 
}

.word-breakdown-group:last-child { 
    margin-bottom: 0; 
}

.word-breakdown-title { 
    font-weight: 800; 
    color: var(--highlight); 
    margin-bottom: 4px; 
    font-size: 14px; 
    text-transform: uppercase; 
}

.word-breakdown-list { 
    color: #ddd; 
    line-height: 1.6; 
    font-size: 14px; 
}

/* Light mode overrides */
body.light-mode .word-breakdown-container {
    background: rgba(0,0,0,0.03) !important;
    border-color: #cbd5e1 !important;
}

body.light-mode .word-breakdown-title { 
    color: #27ae60 !important; 
}

body.light-mode .word-breakdown-list { 
    color: #475569 !important; 
}

/* --- TROPHY POPUP ANIMATION --- */
.trophy-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px; 
    z-index: 1000;
    pointer-events: none;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trophy-pop-anim {
    animation: trophyPopFade 2.0s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes trophyPopFade {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -80%) scale(0.8); opacity: 0; }
}

/* --- DAILY CROWN POPUP ANIMATION --- */
.crown-pop-in {
    animation: crownPopIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes crownPopIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- WILDCARD SUBMIT BUTTON HOVER --- */
#submit-wildcard-btn:active {
    transform: scale(0.9) !important;
}

/* =========================================
   TUTORIAL MODAL STYLES
   ========================================= */
.tutorial-slide { 
    display: none; 
    animation: dropIn 0.3s cubic-bezier(0.25, 1, 0.5, 1) backwards; 
}
.tutorial-slide.active-slide { 
    display: block; 
}
.tut-dot { 
    width: 10px; 
    height: 10px; 
    background: #555; 
    border-radius: 50%; 
    transition: background 0.3s, transform 0.2s; 
}
.tut-dot.active-dot { 
    background: var(--highlight); 
    transform: scale(1.3);
}

body.light-mode .tut-dot { background: #cbd5e1; }
body.light-mode .tut-dot.active-dot { background: #3498db; }

/* =========================================
   TUTORIAL ANIMATIONS
   ========================================= */
.tut-anim-container {
    position: relative;
    width: 100%;
    max-width: 250px; 
    margin: 0 auto 15px auto;
    border: 2px solid #333;
    border-radius: 8px;
    overflow: hidden;
}

.tut-anim-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: auto;
}

/* Image 1 sits permanently on the bottom to give the container its height */
.tut-anim-img:nth-child(1) {
    position: relative; 
    z-index: 1;
}

/* Images 2, 3, and 4 fade in and out on top of Image 1 */
.tut-anim-img:nth-child(2) { animation: tutFadeOver 12s infinite 3s; z-index: 2; opacity: 0; }
.tut-anim-img:nth-child(3) { animation: tutFadeOver 12s infinite 6s; z-index: 2; opacity: 0; }
.tut-anim-img:nth-child(4) { animation: tutFadeOver 12s infinite 9s; z-index: 2; opacity: 0; }

@keyframes tutFadeOver {
    0%   { opacity: 0; }
    5%   { opacity: 1; }   
    28%  { opacity: 1; }   /* Extended: Stays solid while next image fades in */
    33%  { opacity: 0; }   /* Shifted: Safely fades out once covered */
    100% { opacity: 0; }   
}

/* Slide 2 (3 Images: 9s total loop) */
.tut-anim-3 .tut-anim-img:nth-child(2) { animation: tutFadeOver3 9s infinite 3s; z-index: 2; opacity: 0; }
.tut-anim-3 .tut-anim-img:nth-child(3) { animation: tutFadeOver3 9s infinite 6s; z-index: 2; opacity: 0; }

@keyframes tutFadeOver3 {
    0%   { opacity: 0; }
    6.6% { opacity: 1; }   
    38%  { opacity: 1; }   /* Extended past 33.3% */
    44%  { opacity: 0; }   
    100% { opacity: 0; }   
}

/* Slide 3 (5 Images: 15s total loop) */
.tut-anim-5 .tut-anim-img:nth-child(2) { animation: tutFadeOver5 15s infinite 3s; z-index: 2; opacity: 0; }
.tut-anim-5 .tut-anim-img:nth-child(3) { animation: tutFadeOver5 15s infinite 6s; z-index: 2; opacity: 0; }
.tut-anim-5 .tut-anim-img:nth-child(4) { animation: tutFadeOver5 15s infinite 9s; z-index: 2; opacity: 0; }
.tut-anim-5 .tut-anim-img:nth-child(5) { animation: tutFadeOver5 15s infinite 12s; z-index: 2; opacity: 0; }

@keyframes tutFadeOver5 {
    0%   { opacity: 0; }
    4%   { opacity: 1; }   
    23%  { opacity: 1; }   /* Extended past 20% */
    27%  { opacity: 0; }   
    100% { opacity: 0; }   
}

/* Light Mode support */
body.light-mode .tut-anim-container { border-color: #cbd5e1; }

/* =========================================
   UPDATE NOTIFICATION BANNER
   ========================================= */
.v2-banner-container {
    position: fixed;
    /* Uses 44px as a hard fallback if the Capacitor webview drops the variable */
    top: calc(env(safe-area-inset-top, 44px) + 15px); 
    left: 0;
    width: 100%;
    z-index: 9999;
    display: flex;
    justify-content: center;
    padding: 0 15px;
    box-sizing: border-box;
    pointer-events: none;
}

.v2-update-tab {
    background: rgba(142, 68, 173, 0.95); 
    backdrop-filter: blur(4px); 
    color: white;
    padding: 15px 35px 15px 20px; 
    /* Make it a true floating card by rounding all 4 corners! */
    border-radius: 12px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 550px; 
    position: relative;
    pointer-events: auto;
    text-align: center;
    animation: dropIn 0.5s cubic-bezier(0.25, 1, 0.5, 1) backwards;
}

.v2-update-tab p { color: #fff !important; }

.v2-update-tab a {
    color: #f39c12; /* Scootch Orange */
    font-weight: bold;
    text-decoration: none;
    transition: color 0.2s;
}

.v2-update-tab a:hover {
    color: #fff;
}

#close-v2-banner {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1;
    transition: color 0.2s;
}

#close-v2-banner:hover {
    color: white;
}

/* =========================================
   MOBILE TUTORIAL MODAL FIX
   ========================================= */
@media (max-width: 600px) {
    #tutorial-modal .modal-content {
        display: flex;
        flex-direction: column;
        max-height: 85vh !important; /* Caps the modal so it never goes off-screen */
        padding: 20px 15px !important;
    }
    
    #tutorial-slides {
        min-height: 0 !important; /* Overrides the rigid 550px inline style */
        flex-grow: 1; /* Tells the slides to fill the available middle space */
        overflow-y: auto; /* Allows scrolling ONLY inside the slide content */
        padding-bottom: 10px; /* Adds a little breathing room above the dots */
    }

    #tutorial-dots {
        flex-shrink: 0; /* Prevents the dots from being crushed */
        margin: 10px 0 15px 0 !important;
    }

    /* Targets the button container specifically */
    #tutorial-dots + div {
        flex-shrink: 0; /* Prevents the buttons from being crushed */
        padding-bottom: env(safe-area-inset-bottom, 5px); /* Respects the iPhone home bar */
    }
}

/* =========================================
   IOS SAFARI OVERRIDES
   ========================================= */
button, input {
    -webkit-appearance: none;
    appearance: none;
}

.main-btn {
    opacity: 1 !important; /* Stops Safari from auto-dimming the button backgrounds */
    -webkit-text-fill-color: currentcolor; /* Tells Safari to respect YOUR native text colors! */
    
    /* Forces the iPhone GPU to render the true, vibrant hex colors */
    transform: translateZ(0); 
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
}

.main-btn:disabled {
    opacity: 0.4 !important; /* Standardizes the dimming for disabled buttons across all devices */
    cursor: not-allowed;
}

/* --- BUY ME A COFFEE VISIBILITY --- */
body.game-active #bmc-wbtn,
body.game-active #bmc-iframe,
body.game-active [id^="bmc-"] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -9999 !important;
    transform: scale(0) !important;
}
#bmc-wbtn {
    transform: scale(0.8) !important; 
    transform-origin: bottom right !important; 
}