:root {
    --bg-color: #121213;
    --board-bg: #000000;
    --tile-empty: #3a3a3c;
    --tile-border: #3a3a3c;
    --tile-filled: #ffffff;
    --text-color: #ffffff;
    --accent-color: #39a474;
    --accent-yellow: #b59f3b;
    --accent-red: #eb4d4b;
    --overlay-bg: rgba(0, 0, 0, 0.85);
    --font-main: 'Inter', sans-serif;
    --shadow-text: #ffffff;
    --timer-color: #ffffff;
    --loading-shade: rgba(0, 0, 0, 0.4);
    --text-pending: #ffffff;
    --text-confirmed: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.09);
    --accent-glow: rgba(69, 201, 142, 0.25);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

body {
    background-color: var(--bg-color);
    background-image: var(--bg-image, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: var(--text-color);
    font-family: var(--font-main);
    height: 100dvh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app-root {
    width: 100%;
    max-width: 500px;
    height: 100%;
    letter-spacing: 1px;
}

.highlight {
    color: var(--accent-color);
}

.screen-header {
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 15px;
    /* High-Fidelity Glassmorphism */
    background: rgba(14, 18, 26, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    position: relative;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-left {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    z-index: 10;
}

.header-center {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.header-right {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    z-index: 10;
}

/* Unified Coin Display */
.header-coin-display {
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    min-height: 32px;
    white-space: nowrap;
}

.header-coin-display:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
}

/* Custom Scrollbar - Glassmorphism Style */
::-webkit-scrollbar {
    display: none;
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    margin: 3px 0;
    /* Top/Bottom margin for track */
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    border: 2px solid transparent;
    /* Creates padding effect */
    background-clip: content-box;
    /* Ensures background is inside border */
    backdrop-filter: blur(5px);
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4);
}











.icon-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
}

/* Back Button - Fixed to Left Corner */
.back-btn {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

/* Main Container */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    gap: 28px;
    overflow: hidden;
}

/* Score Board */
.score-board {
    display: flex;
    gap: 0;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    overflow: hidden;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 8px 12px 6px;
    background: transparent;
    border: 0;
}

.score-item + .score-item {
    border-left: 1px solid var(--glass-border);
}

.score-item .label {
    font-size: 10px;
    color: #666;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.score-item .value {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-color);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

/* Board Wrapper */
.board-wrapper {
    position: relative;
    border: 2px solid #333;
    border-radius: 4px;
    background: var(--board-bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

canvas {
    display: block;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.hidden {
    display: none !important;
}

.overlay h2 {
    font-size: 24px;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.primary-btn,
.secondary-btn {
    padding: 12px 30px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    margin: 10px;
    border: none;
    min-width: 150px;
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
}

.secondary-btn {
    background-color: transparent;
    border: 2px solid #555;
    color: #ccc;
}

/* Timer Overlay */
#word-timer-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50;
}

.timer-ring {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
}

.progress-ring__circle {
    transition: 0.35s stroke-dashoffset;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    color: white;
}

/* Preview Area */
.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.letter-tile {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: 700;
    background-color: var(--tile-empty);
    border: 2px solid var(--tile-border);
    color: white;
    border-radius: 4px;
}

.letter-tile.preview {
    border-color: var(--accent-yellow);
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    padding: 20px;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #333;
    border: none;
    color: white;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Detected Words List */
.words-list-container {
    width: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #333;
}

.words-list-header {
    font-size: 10px;
    color: #888;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.words-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #222;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid var(--accent-yellow);
}

.word-item.high-value {
    border-left-color: var(--accent-color);
    background: #2a3a2a;
}

.word-text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 1px;
}

.word-info {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #ccc;
}

.word-points {
    color: var(--accent-yellow);
    font-weight: 600;
}

/* Word History Panel */
.word-history-panel {
    width: 90%;
    max-width: 500px;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 16px;
}

.history-header {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    text-align: center;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    color: #666;
    font-size: 13px;
    padding: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #222;
    padding: 10px 14px;
    border-radius: 4px;
}

.history-word {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.history-points {
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 600;
}

/* Specific styling for history list to ensure margin effect */
.history-list::-webkit-scrollbar {
    width: 6px;
    margin: 3px 0;
}

.history-list::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Word Progress Display */
.word-progress-container {
    width: 90%;
    max-width: 400px;
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #333;
    border-radius: 8px;
}

.word-progress-label {
    font-size: 10px;
    font-weight: 700;
    color: #666;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.word-progress-text {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    color: var(--accent-yellow);
    margin-bottom: 8px;
    letter-spacing: 2px;
    min-height: 30px;
}

.word-progress-bar {
    width: 100%;
    height: 8px;
    background: #222;
    border-radius: 4px;
    overflow: hidden;
}

.word-progress-fill {
    height: 100%;
    background: var(--accent-yellow);
    border-radius: 4px;
    transition: all 0.3s ease;
    width: 0%;
}

.word-progress-fill.valid {
    background: var(--accent-color);
}

/* Screens */
.screen {
    width: 100%;
    height: 100%;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Main Menu */
#screen-main-menu {
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(135deg, var(--bg-color), var(--board-bg));
}

.menu-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    flex: 1;
    justify-content: center;
}

.menu-footer {
    position: absolute;
    bottom: 20px;
    font-size: 12px;
    color: #444;
}

.game-title.large {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 4px 10px rgba(83, 141, 78, 0.3);
}

.game-title.small {
    font-size: 24px;
}

.mode-cards-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    border-radius: 16px;
    padding: 20px;
    width: 160px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mode-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
    background: rgba(83, 141, 78, 0.1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.mode-icon {
    font-size: 32px;
}

.mode-card h3 {
    font-size: 18px;
    color: var(--accent-color);
    margin: 0;
}

.mode-card p {
    font-size: 12px;
    color: #888;
    margin: 0;
}

/* Game Area Layout */
.game-area {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 600px;
}

.side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 80px;
}

.panel-label {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    letter-spacing: 1px;
}

.tile-display {
    width: 60px;
    height: 60px;
    border: 2px solid #333;
    border-radius: 8px;
    background: var(--tile-empty);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: white;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.tile-display.empty {
    color: #555;
    border-style: dashed;
}

.key-hint {
    font-size: 10px;
    color: #555;
    background: #222;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .game-area {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
        width: 100%;
    }

    .board-wrapper {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .side-panel {
        flex-direction: column;
        width: auto;
        grid-row: 1;
    }

    .side-panel:first-child {
        grid-column: 1;
        align-items: flex-end;
        padding-right: 20px;
    }

    .side-panel:last-child {
        grid-column: 3;
        align-items: flex-start;
        padding-left: 20px;
    }

    .side-panel .panel-label {
        display: none;
    }

    .tile-display {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}

/* Drop Beam Effect */
.drop-beam {
    position: absolute;
    top: 0;
    /* width and height set by JS */
    background: linear-gradient(to bottom, transparent, var(--beam-color));
    pointer-events: none;
    animation: beamFade 0.4s ease-out forwards;
    z-index: 5;
}

@keyframes beamFade {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }

    20% {
        opacity: 1;
        transform: scaleX(1);
    }

    100% {
        opacity: 0;
        transform: scaleX(1.2);
    }
}

/* Word Progress Colors */
.word-progress-text.pending {
    color: var(--accent-yellow);
}

.word-progress-text.confirmed {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    animation: popWord 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popWord {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Pending Words Container (New Location) */
.pending-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 30px;
}

#pending-words-panel {
    position: absolute;
    top: 10px;
    right: -140px;
    /* Position to the right of the board */
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pending-word-item {
    background: rgba(0, 0, 0, 0.6);
    color: var(--accent-yellow);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    border-left: 2px solid var(--accent-yellow);
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
}

.pending-word-item .score {
    font-size: 10px;
    color: #aaa;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pre-forming Word Suggestions */
.preforming-word-item {
    background: rgba(0, 0, 0, 0.4);
    color: #666;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    border-left: 2px solid #444;
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0.7;
}

.word-suggestion {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    position: relative;
}

.preforming-word-item:hover {
    opacity: 1;
    border-radius: 8px;
    background: var(--tile-empty);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.tile-display.empty {
    color: #555;
    border-style: dashed;
}

.key-hint {
    font-size: 10px;
    color: #555;
    background: #222;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .game-area {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
        width: 100%;
    }

    .board-wrapper {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .side-panel {
        flex-direction: column;
        width: auto;
        grid-row: 1;
    }

    .side-panel:first-child {
        grid-column: 1;
        align-items: flex-end;
        padding-right: 20px;
    }

    .side-panel:last-child {
        grid-column: 3;
        align-items: flex-start;
        padding-left: 20px;
    }

    .side-panel .panel-label {
        display: none;
    }

    .tile-display {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}

/* Drop Beam Effect */
.drop-beam {
    position: absolute;
    top: 0;
    /* width and height set by JS */
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.4) 100%);
    pointer-events: none;
    animation: beamFade 0.4s ease-out forwards;
    z-index: 5;
}

@keyframes beamFade {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }

    20% {
        opacity: 1;
        transform: scaleX(1);
    }

    100% {
        opacity: 0;
        transform: scaleX(1.2);
    }
}

/* Word Progress Colors */
.word-progress-text.pending {
    color: var(--accent-yellow);
}

.word-progress-text.confirmed {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    animation: popWord 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popWord {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Pending Words Container (New Location) */
.pending-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 30px;
}

#pending-words-panel {
    position: absolute;
    top: 10px;
    right: -140px;
    /* Position to the right of the board */
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pending-word-item {
    background: rgba(0, 0, 0, 0.6);
    color: var(--accent-yellow);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    border-left: 2px solid var(--accent-yellow);
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
}

.pending-word-item .score {
    font-size: 10px;
    color: #aaa;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pre-forming Word Suggestions */
.preforming-word-item {
    background: rgba(0, 0, 0, 0.4);
    color: #666;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    border-left: 2px solid #444;
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0.7;
}

.word-suggestion {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    position: relative;
}

.preforming-word-item:hover {
    opacity: 1;
    border-left-color: #666;
    background: rgba(0, 0, 0, 0.5);
}

/* Style the ??? to be more subtle */
.word-suggestion::before {
    content: '💡';
    margin-right: 4px;
    font-size: 11px;
    opacity: 0.5;
}

/* Shadow Preview Style (Grey) */
.pending-word-item.shadow-preview {
    color: #aaa;
    /* Grey text */
    border-left-color: #666;
    color: #555;
    background: #222;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .game-area {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
        width: 100%;
    }

    .board-wrapper {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .side-panel {
        flex-direction: column;
        width: auto;
        grid-row: 1;
    }

    .side-panel:first-child {
        grid-column: 1;
        align-items: flex-end;
        padding-right: 20px;
    }

    .side-panel:last-child {
        grid-column: 3;
        align-items: flex-start;
        padding-left: 20px;
    }

    .side-panel .panel-label {
        display: none;
    }

    .tile-display {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}

/* Drop Beam Effect */
.drop-beam {
    position: absolute;
    top: 0;
    /* width and height set by JS */
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.4) 100%);
    pointer-events: none;
    animation: beamFade 0.4s ease-out forwards;
    z-index: 5;
}

@keyframes beamFade {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }

    20% {
        opacity: 1;
        transform: scaleX(1);
    }

    100% {
        opacity: 0;
        transform: scaleX(1.2);
    }
}

/* Word Progress Colors */
.word-progress-text.pending {
    color: var(--accent-yellow);
}

.word-progress-text.confirmed {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    animation: popWord 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popWord {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Pending Words Container (New Location) */
.pending-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 30px;
}

#pending-words-panel {
    position: absolute;
    top: 10px;
    right: -140px;
    /* Position to the right of the board */
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pending-word-item {
    background: rgba(0, 0, 0, 0.6);
    color: var(--accent-yellow);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    border-left: 2px solid var(--accent-yellow);
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
}

.pending-word-item .score {
    font-size: 10px;
    color: #aaa;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pre-forming Word Suggestions */
.preforming-word-item {
    background: rgba(0, 0, 0, 0.4);
    color: #666;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    border-left: 2px solid #444;
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0.7;
}

.word-suggestion {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    position: relative;
}

.preforming-word-item:hover {
    opacity: 1;
    border-left-color: #666;
    background: rgba(0, 0, 0, 0.5);
}

/* Style the ??? to be more subtle */
.word-suggestion::before {
    content: '💡';
    margin-right: 4px;
    font-size: 11px;
    opacity: 0.5;
}

/* Shadow Preview Style (Grey) */
.pending-word-item.shadow-preview {
    color: #aaa;
    /* Grey text */
    border-left-color: #666;
    /* Grey border */
    background: rgba(0, 0, 0, 0.4);
    /* Slightly more transparent background */
}

.pending-word-item.shadow-preview .score {
    color: #666;
    /* Darker grey score */
}

/* Game Juice Updates */
.pending-word-item {
    transition: all 0.3s ease;
}

.pending-word-item.pending {
    color: var(--accent-yellow);
    border-left-color: var(--accent-yellow);
}

.pending-word-item.confirmed {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    width: auto;
    grid-row: 1;
}

.side-panel:first-child {
    grid-column: 1;
    align-items: flex-end;
    padding-right: 20px;
}

.side-panel:last-child {
    grid-column: 3;
    align-items: flex-start;
    padding-left: 20px;
}

.side-panel .panel-label {
    display: none;
}

.tile-display {
    width: 50px;
    height: 50px;
    font-size: 24px;
}


/* Drop Beam Effect */
.drop-beam {
    position: absolute;
    top: 0;
    /* width and height set by JS */
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.4) 100%);
    pointer-events: none;
    animation: beamFade 0.4s ease-out forwards;
    z-index: 5;
}

@keyframes beamFade {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }

    20% {
        opacity: 1;
        transform: scaleX(1);
    }

    100% {
        opacity: 0;
        transform: scaleX(1.2);
    }
}

/* Word Progress Colors */
.word-progress-text.pending {
    color: var(--accent-yellow);
}

.word-progress-text.confirmed {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    animation: popWord 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popWord {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Pending Words Container (New Location) */
.pending-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 30px;
}

#pending-words-panel {
    position: absolute;
    top: 10px;
    right: -140px;
    /* Position to the right of the board */
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pending-word-item {
    background: rgba(0, 0, 0, 0.6);
    color: var(--accent-yellow);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    border-left: 2px solid var(--accent-yellow);
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
}

.pending-word-item .score {
    font-size: 10px;
    color: #aaa;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pre-forming Word Suggestions */
.preforming-word-item {
    background: rgba(0, 0, 0, 0.4);
    color: #666;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    border-left: 2px solid #444;
    animation: slideIn 0.2s ease-out;
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0.7;
}

.word-suggestion {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    position: relative;
}

.preforming-word-item:hover {
    opacity: 1;
    border-left-color: #666;
    background: rgba(0, 0, 0, 0.5);
}

/* Style the ??? to be more subtle */
.word-suggestion::before {
    content: '💡';
    margin-right: 4px;
    font-size: 11px;
    opacity: 0.5;
}

/* Shadow Preview Style (Grey) */
.pending-word-item.shadow-preview {
    color: #aaa;
    /* Grey text */
    border-left-color: #666;
    /* Grey border */
    background: rgba(0, 0, 0, 0.4);
    /* Slightly more transparent background */
}

.pending-word-item.shadow-preview .score {
    color: #666;
    /* Darker grey score */
}

/* Game Juice Updates */
.pending-word-item {
    transition: all 0.3s ease;
}

.pending-word-item.pending {
    color: var(--accent-yellow);
    border-left-color: var(--accent-yellow);
}

.pending-word-item.confirmed {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    background: rgba(83, 141, 78, 0.2);
    transform: scale(1.1);
    animation: popWordTag 0.5s ease-out forwards;
}

@keyframes popWordTag {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* --- Menus & Progression Styles --- */

/* Menu Buttons */
.menu-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    max-width: 340px;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #ccc;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s;
    height: 70px;
}

.menu-btn .icon {
    font-size: 24px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #666;
    color: white;
}

.coin-display {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-yellow);
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #444;
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    flex-direction: column;
    gap: 15px;
    margin: 0 auto;
}

/* Custom Scrollbar Styling */
.screen-content::-webkit-scrollbar {
    width: 8px;
}

.screen-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* For Firefox */
.screen-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(0, 0, 0, 0.3);
}

.theme-item {
    background: #222;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: flex-start;
    /* Changed from space-between */
    align-items: center;
    gap: 15px;
}

.theme-item-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    text-align: left;
}

.theme-item.active {
    border-color: var(--accent-color);
    background: rgba(83, 141, 78, 0.1);
}

.theme-preview-tile {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid #222;
    /* Add this back for the border */
}

.theme-info {
    text-align: left;
}

.theme-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
    text-align: left;
}

.theme-info p {
    font-size: 12px;
    color: #888;
    text-align: left;
}

.buy-btn {
    background: var(--accent-yellow);
    color: black;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}

.buy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.use-btn {
    background: #444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}

.use-btn.active {
    background: var(--accent-color);
    cursor: default;
}


/* --- Word Detail Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2c2c2e;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #fff;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: #fff;
}

#word-detail-header {
    margin: 0 0 10px 0;
    font-size: 32px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.phonetic {
    color: #aaa;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 18px;
}

.meanings {
    max-height: 300px;
    overflow-y: auto;
}

.meaning-group {
    margin-bottom: 15px;
}

.part-of-speech {
    color: #b59f3b;
    /* Yellow */
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 14px;
}

.definition-item {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #ddd;
}

.definition-example {
    color: #888;
    color: white;
}

/* Store */
.theme-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.theme-item {
    background: #222;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.theme-item.active {
    border-color: var(--accent-color);
    background: rgba(83, 141, 78, 0.1);
}

.theme-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.theme-info p {
    font-size: 12px;
    color: #888;
}

.buy-btn {
    background: var(--accent-yellow);
    color: black;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}

.buy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.use-btn {
    background: #444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}

.use-btn.active {
    background: var(--accent-color);
    cursor: default;
}

/* Themes */
.theme-typewriter {
    --font-main: 'Courier New', monospace;
    --bg-color: #f5f5dc;
    --text-color: #333;
    --board-bg: #e8e8d0;
    --tile-empty: #d0d0b0;
    --tile-filled: #fff;
    --tile-border: #8b4513;
    --accent-color: #8b4513;
    --accent-yellow: #cd853f;
}

.theme-comic {
    --font-main: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    --accent-color: #ff6b6b;
    --accent-yellow: #feca57;
    --bg-color: #2f3542;
    --board-bg: #57606f;
}

.theme-modern {
    --font-main: 'Helvetica Neue', sans-serif;
    --bg-color: #2d3436;
    --board-bg: #636e72;
    --tile-empty: #b2bec3;
    --tile-filled: #dfe6e9;
    --text-color: #fff;
    --accent-color: #00cec9;
    --accent-yellow: #fdcb6e;
}

/* --- Word Detail Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2c2c2e;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #fff;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: #fff;
}

#word-detail-header {
    margin: 0 0 10px 0;
    font-size: 32px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.phonetic {
    color: #aaa;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 18px;
}

.meanings {
    max-height: 300px;
    overflow-y: auto;
}

.meaning-group {
    margin-bottom: 15px;
}

.part-of-speech {
    color: #b59f3b;
    /* Yellow */
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 14px;
}

.definition-item {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #ddd;
}

.definition-example {
    color: #888;
    font-style: italic;
    margin-top: 4px;
    font-size: 14px;
}

/* Make dictionary items clickable */
.dict-item.unlocked {
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.dict-item.unlocked:hover {
    transform: scale(1.05);
    background: #444;
    z-index: 10;
}

/* Alternating rows for dictionary */
.dict-item:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.dict-item:nth-child(even) {
    background: rgba(0, 0, 0, 0.15);
}


.new-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

}

.theme-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.theme-info p {
    font-size: 12px;
    color: #888;
}

.buy-btn {
    background: var(--accent-yellow);
    color: black;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}

.buy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.use-btn {
    background: #444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}

.use-btn.active {
    background: var(--accent-color);
    cursor: default;
}

/* Themes */
.theme-typewriter {
    --font-main: 'Courier New', monospace;
    --bg-color: #f5f5dc;
    --text-color: #333;
    --board-bg: #e8e8d0;
    --tile-empty: #d0d0b0;
    --tile-filled: #fff;
    --tile-border: #8b4513;
    --accent-color: #8b4513;
    --accent-yellow: #cd853f;
}

.theme-comic {
    --font-main: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    --accent-color: #ff6b6b;
    --accent-yellow: #feca57;
    --bg-color: #2f3542;
    --board-bg: #57606f;
}

.theme-modern {
    --font-main: 'Helvetica Neue', sans-serif;
    --bg-color: #2d3436;
    --board-bg: #636e72;
    --tile-empty: #b2bec3;
    --tile-filled: #dfe6e9;
    --text-color: #fff;
    --accent-color: #00cec9;
    --accent-yellow: #fdcb6e;
}

/* --- Word Detail Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2c2c2e;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #fff;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: #fff;
}

#word-detail-header {
    margin: 0 0 10px 0;
    font-size: 32px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.phonetic {
    color: #aaa;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 18px;
}

.meanings {
    max-height: 300px;
    overflow-y: auto;
}

.meaning-group {
    margin-bottom: 15px;
}

.part-of-speech {
    color: #b59f3b;
    /* Yellow */
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 14px;
}

.definition-item {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #ddd;
}

.definition-example {
    color: #888;
    font-style: italic;
    margin-top: 4px;
    font-size: 14px;
}

/* Make dictionary items clickable */
.dict-item.unlocked {
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.dict-item.unlocked:hover {
    transform: scale(1.05);
    background: #444;
    z-index: 10;
}

.new-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

/* History List Updates */
.history-word-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-new-badge {
    font-size: 9px;
    background: var(--accent-yellow);
    color: #111;
    padding: 2px 5px;
    border-radius: 3px;
}

/* Themes */
.theme-typewriter {
    --font-main: 'Courier New', monospace;
    --bg-color: #f5f5dc;
    --text-color: #333;
    --board-bg: #e8e8d0;
    --tile-empty: #d0d0b0;
    --tile-filled: #fff;
    --tile-border: #8b4513;
    --accent-color: #8b4513;
    --accent-yellow: #cd853f;
}

.theme-comic {
    --font-main: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    --accent-color: #ff6b6b;
    --accent-yellow: #feca57;
    --bg-color: #2f3542;
    --board-bg: #57606f;
}

.theme-modern {
    --font-main: 'Helvetica Neue', sans-serif;
    --bg-color: #2d3436;
    --board-bg: #636e72;
    --tile-empty: #b2bec3;
    --tile-filled: #dfe6e9;
    --text-color: #fff;
    --accent-color: #00cec9;
    --accent-yellow: #fdcb6e;
}

/* --- Word Detail Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2c2c2e;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #fff;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: #fff;
}

#word-detail-header {
    margin: 0 0 10px 0;
    font-size: 32px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.phonetic {
    color: #aaa;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 18px;
}

.meanings {
    max-height: 300px;
    overflow-y: auto;
}

.meaning-group {
    margin-bottom: 15px;
}

.part-of-speech {
    color: #b59f3b;
    /* Yellow */
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 14px;
}

.definition-item {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #ddd;
}

.definition-example {
    color: #888;
    font-style: italic;
    margin-top: 4px;
    font-size: 14px;
}

/* Make dictionary items clickable */
.dict-item.unlocked {
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.dict-item.unlocked:hover {
    transform: scale(1.05);
    background: #444;
    z-index: 10;
}

.new-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

/* History List Updates */
.history-word-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-new-badge {
    font-size: 9px;
    background: var(--accent-yellow);
    color: #111;
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 800;
    letter-spacing: 0.5px;
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.8;
    }
}

/* Override New Badge for Dictionary */
.new-badge {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: var(--accent-yellow);
    color: #111;
    --text-color: #333;
    --board-bg: #e8e8d0;
    --tile-empty: #d0d0b0;
    --tile-filled: #fff;
    --tile-border: #8b4513;
    --accent-color: #8b4513;
    --accent-yellow: #cd853f;
}

.theme-comic {
    --font-main: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    --accent-color: #ff6b6b;
    --accent-yellow: #feca57;
    --bg-color: #2f3542;
    --board-bg: #57606f;
}

.theme-modern {
    --font-main: 'Helvetica Neue', sans-serif;
    --bg-color: #2d3436;
    --board-bg: #636e72;
    --tile-empty: #b2bec3;
    --tile-filled: #dfe6e9;
    --text-color: #fff;
    --accent-color: #00cec9;
    --accent-yellow: #fdcb6e;
}

/* --- Word Detail Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2c2c2e;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #444;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #fff;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: #fff;
}

#word-detail-header {
    margin: 0 0 10px 0;
    font-size: 32px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.phonetic {
    color: #aaa;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 18px;
}

.meanings {
    max-height: 300px;
    overflow-y: auto;
}

.meaning-group {
    margin-bottom: 15px;
}

.part-of-speech {
    color: #b59f3b;
    /* Yellow */
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 14px;
}

.definition-item {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #ddd;
}

.definition-example {
    color: #888;
    font-style: italic;
    margin-top: 4px;
    font-size: 14px;
}

/* Make dictionary items clickable */
.dict-item.unlocked {
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.dict-item.unlocked:hover {
    transform: scale(1.05);
    background: #444;
    z-index: 10;
}

.new-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

/* History List Updates */
.history-word-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-new-badge {
    font-size: 9px;
    background: var(--accent-yellow);
    color: #111;
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 800;
    letter-spacing: 0.5px;
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.8;
    }
}

/* Settings Screen */
.settings-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-section h3 {
    font-size: 14px;
    color: var(--accent-yellow);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #333;
}

.setting-item span {
    font-size: 14px;
    color: #ccc;
}

.setting-item:last-child {
    border-bottom: none;
}


/* Toggle Group */
.toggle-group {
    display: flex;
    background: #222;
    border-radius: 4px;
    padding: 2px;
    border: 1px solid #444;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: #666;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: #444;
    color: #fff;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}


.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: 0.3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

/* Danger Button */
.danger-btn {
    background: #d32f2f;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 10px;
}

.danger-btn:hover {
    background: #b71c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(211, 47, 47, 0.3);
}

.warning-text {
    font-size: 12px;
    color: #888;
    text-align: center;
    margin: 0;
}

/* Confirmation Dialog */
.confirm-dialog {
    max-width: 400px;
}

.confirm-dialog h3 {
    margin-top: 0;
    color: #d32f2f;
}

.confirm-dialog ul {
    text-align: left;
    margin: 15px 0;
    padding-left: 25px;
}

.confirm-dialog li {
    margin: 8px 0;
    color: #ccc;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.dialog-buttons button {
    flex: 1;
}

/* Daily Challenge Screen */
.challenge-date {
    text-align: center;
    font-size: 14px;
    color: #888;
    margin-bottom: 20px;
}

/* Main Card */
.challenge-card {
    background: rgba(25, 22, 22, 0.05);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.challenge-name {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.challenge-desc {
    color: #aaa;
    margin-bottom: 20px;
}

/* Task */
.challenge-task {
    margin-bottom: 20px;
}

.task-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Progress */
.progress-container {
    margin-top: 12px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-yellow));
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: #aaa;
}

/* Reward */
.challenge-reward {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    margin-bottom: 16px;
}

.reward-label {
    font-weight: 600;
    color: #aaa;
}

.reward-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-yellow);
}

/* Status */
.challenge-status {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
}

.challenge-status.completed {
    background: rgba(83, 141, 78, 0.2);
    color: var(--accent-color);
}

.challenge-status.in-progress {
    background: rgba(181, 159, 59, 0.2);
    color: var(--accent-yellow);
}

/* Actions */
.challenge-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Coin Shop */
.coin-packages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.coin-package {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid var(--accent-color);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
}

.coin-package:hover {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.2), rgba(155, 89, 182, 0.1));
}

.coin-package.special {
    border-color: #e74c3c;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.2), rgba(231, 76, 60, 0.1));
}

.popular-badge {
    position: absolute;
    top: -10px;
    right: 10px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.5);
}

.package-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.package-amount {
    font-size: 1.3em;
    font-weight: bold;
    margin: 10px 0;
}

.package-price {
    font-size: 1.8em;
    color: var(--accent-yellow);
    font-weight: bold;
    margin: 10px 0;
}

.package-note {
    font-size: 0.85em;
    color: #aaa;
    font-style: italic;
}

/* Daily Challenge Upcoming Rewards */
.upcoming-rewards {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rewards-header {
    text-align: center;
    color: var(--accent-yellow);
    margin-bottom: 20px;
    font-size: 1.2em;
}

.rewards-timeline {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 5px;
    scroll-behavior: smooth;
}

.reward-card {
    min-width: 140px;
    background: linear-gradient(135deg, rgba(83, 141, 78, 0.2), rgba(83, 141, 78, 0.1));
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: transform 0.3s ease;
}

.reward-card.today {
    border-color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
    transform: scale(1.05);
}

.reward-card.locked {
    opacity: 0.6;
    border-color: #666;
}

.reward-card:hover {
    transform: translateY(-5px);
}

.reward-date {
    font-size: 0.8em;
    color: #aaa;
    margin-bottom: 5px;
}

.reward-icon {
    font-size: 2.5em;
    margin: 10px 0;
}

.reward-name {
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #fff;
}

.reward-value {
    color: var(--accent-yellow);
    font-size: 0.85em;
    margin-top: 5px;
}

.reward-badge {
    display: inline-block;
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid #ffd700;
    border-radius: 10px;
    padding: 3px 8px;
    font-size: 0.7em;
    margin-top: 5px;
    color: #ffd700;
}

.reward-locked {
    font-size: 3em;
    color: #666;
}

/* Game Over Button Containers */
#game-over-normal-buttons,
#game-over-story-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* --- Challenge Mode HUD + Story Win Modal Enhancements --- */
.make-word-panel {
    width: min(100%, 420px);
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-align: center;
}

.make-word-label {
    font-size: 11px;
    letter-spacing: 1px;
    color: #9ab3d9;
    font-weight: 700;
}

.make-word-target {
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    color: #f5f9ff;
}

.make-word-subtext {
    font-size: 11px;
    color: #93a0ba;
}

.story-complete-card {
    position: relative;
    z-index: 2;
    width: min(92%, 360px);
    padding: 22px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(8, 10, 18, 0.9);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.story-complete-card h2 {
    margin-bottom: 4px;
    color: #ffd92f;
}

.story-complete-card p {
    text-align: center;
    color: #d8d8d8;
    margin-bottom: 6px;
}

.confetti-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.confetti {
    position: absolute;
    top: -12%;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    opacity: 0.9;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(130%) rotate(540deg);
    }
}

.quick-keys {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: -6px;
    font-size: 11px;
    color: #a9b4ca;
}

.quick-keys span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.quick-keys kbd {
    min-width: 18px;
    padding: 2px 5px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.07);
    font: inherit;
    font-weight: 700;
    color: #f4f8ff;
    text-align: center;
}

.story-level-brief {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    padding: 20px;
}

.story-level-brief-card {
    width: min(92%, 430px);
    background: rgba(10, 12, 20, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 18px;
}

.story-level-brief-card h3 {
    margin-bottom: 8px;
    color: #f1f6ff;
}

.story-level-brief-card p {
    margin-bottom: 10px;
    color: #b8c5de;
}

.story-level-brief-card ul {
    margin: 0 0 12px 18px;
    color: #d8e0f0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.story-level-brief-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

/* --- STATS & LEADERBOARD TABS --- */
.stats-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    width: 100%;
    background: rgba(0,0,0,0.2);
}

.stats-tab {
    padding: 10px 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    color: #888;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stats-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.stats-tab-content {
    flex: 1;
    width: 100%;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.career-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.career-stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.career-stat-card .label {
    font-size: 10px;
    color: #666;
    font-weight: 800;
    letter-spacing: 1px;
}

.career-stat-card .value {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-color);
}

.recent-achievements {
    background: rgba(255,255,255,0.03);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}

.recent-achievements h4 {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 12px;
    text-align: center;
}

/* Leaderboard Items in Stats */
.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.leaderboard-item.top-three .rank {
    color: var(--gold-color, #f1c40f);
}

.leaderboard-item .name {
    flex: 1;
    margin-left: 15px;
    font-weight: 700;
}

/* ================================================================
   DESKTOP & TABLET RESPONSIVE LAYOUT (900px+)
   Game switches to 2-column: board left, word list right
   ================================================================ */
@media (min-width: 900px) {
    #screen-game .game-container {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        padding: 20px 28px;
        gap: 24px;
        overflow-y: auto;
    }

    /* Left column: all board elements stacked */
    .game-left-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        flex: 0 0 auto;
    }

    /* Keep game-area tight around hold+board+next; JS handles canvas sizing */
    .game-left-col .game-area {
        max-width: none;
    }

    /* Score on desktop */
    .game-left-col .score-board {
        gap: 12px;
    }

    .game-left-col .score-item .value {
        font-size: 32px;
    }

    /* Quick keys compact */
    .game-left-col .quick-keys {
        opacity: 0.7;
        font-size: 10px;
    }

    /* Word list: right column, sticky */
    #screen-game #unified-word-list-container {
        width: 220px;
        flex: 0 0 220px;
        max-height: calc(100dvh - 64px - 40px);
        margin-top: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        align-self: flex-start;
        position: sticky;
        top: 0;
    }

    #screen-game #unified-word-list-container .unified-list {
        max-height: none;
        flex: 1;
        overflow-y: auto;
    }
}

/* iPad Portrait (768px-899px) */
@media (min-width: 768px) and (max-width: 899px) {
    #screen-game .game-container {
        gap: 16px;
        padding: 16px 20px;
    }
}
