/* ===========================
   WordWrap - CSS Styles
   Theme: Ancient Mahjong
   =========================== */

:root {
    /* Color Palette - Modern Clean Theme */
    --background: hsl(0, 0%, 96%);
    --foreground: hsl(0, 0%, 9%);
    --primary: hsl(161, 93%, 30%);
    --primary-foreground: hsl(151, 80%, 95%);
    --secondary: hsl(0, 0%, 32%);
    --secondary-foreground: hsl(0, 0%, 98%);
    --muted: hsl(0, 0%, 63%);
    --muted-foreground: hsl(0, 0%, 9%);
    --border: hsl(0, 0%, 83%);

    /* Game specific colors */
    --tile-ivory: #f5f1e8;
    --tile-border: #d4c5a9;
    --tile-grey: #6b5d4f;
    --success-green: #26815f;
    --success-glow: #6fa87d;

    /* UI Colors */
    --bg-charcoal: #2a2520;
    --text-white: #ffffff;
    --btn-primary: #b4895e;
    --btn-hover: #9d7850;

    /* Fonts - Updated for retro design */
    --font-display: 'Righteous', cursive;
    --font-body: 'Space Mono', monospace;
    --font-tile: 'Bitter', serif;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Shadows */
    --shadow-soft: 0 4px 24px -4px rgba(0, 0, 0, 0.08);
    --shadow-elevated: 0 8px 32px -8px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --transition-fast: 0.2s ease-out;
    --transition-normal: 0.3s ease-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile (accounts for browser chrome) */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Grid pattern background */
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
}

/* ===========================
   Screen Management
   =========================== */

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    padding: 1.5rem; /* px-6 = 1.5rem */
    position: relative;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    padding-bottom: 5rem; /* Space for footer */
}

/* ===========================
   v2.1 Retro Design Elements
   =========================== */

/* Gradient Blobs */
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    pointer-events: none;
    z-index: 1;
}

.blob-yellow {
    top: 40px;
    left: -80px;
    width: 136px;
    height: 136px;
    background: #facc15; /* yellow-400 */
    opacity: 0.6;
    animation: pulse-slow 3s ease-in-out infinite;
}

.blob-cyan {
    bottom: 120px;
    right: -80px;
    width: 204px;
    height: 204px;
    background: var(--primary);
    opacity: 0.5;
    animation: pulse-slow 3s ease-in-out infinite;
    animation-delay: 1s;
}

@keyframes pulse-slow {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Title Section */
.title-section {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    z-index: 10;
}

/* Logo Home Link - Clickable logo on game/leaderboard pages */
.logo-home-link {
    cursor: pointer;
    display: inline-block;
    transition: opacity var(--transition-fast);
    text-align: center;
}

.logo-home-link:hover {
    opacity: 0.7;
}

.logo-home-link:active {
    opacity: 0.5;
}

/* Material Icons */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga';
}

/* ===========================
   Typography
   =========================== */

/* Text Stroke Effect for WRAPSTACK */
.game-title {
    position: relative;
    display: inline-block;
    font-family: var(--font-display);
    font-size: 4.5rem;
    font-weight: 400;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: -0.05em;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.title-text {
    position: relative;
    z-index: 2;
    color: var(--foreground);
}

.title-stroke {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 1;
    color: transparent;
    -webkit-text-stroke: 1px var(--primary);
    text-stroke: 1px var(--primary);
    opacity: 0.7;
    pointer-events: none;
}

.game-title-small {
    font-size: 1.5rem;
    margin-bottom: 0;
    letter-spacing: -0.025em;
}

.game-title-game {
    font-size: 4.5rem; /* Match home page: 72px */
    margin-bottom: 0;
    line-height: 1; /* Tight line-height */
}

.game-title-game.game-title-daily {
    font-size: 3.75rem; /* Match home page: 60px */
    color: var(--primary);
    margin-top: 0.5rem; /* Match home page spacing */
    margin-bottom: 0;
    line-height: 1; /* Tight line-height */
    animation: none;
}

.game-title-daily {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 400;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    line-height: 1;
    margin-top: 0;
    margin-bottom: 0;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.2);
}

/* Tagline */
.title-tagline {
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tagline-line {
    width: 2rem;
    height: 1px;
    background: var(--muted);
}

.game-header {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.game-subtitle {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin: 0;
}

.leaderboard-subtitle {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    color: var(--foreground);
    margin-top: 1rem;
    margin-bottom: 0;
}

.todays-date {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
    margin-top: 1.5rem; /* mt-6 = 1.5rem */
    margin-bottom: 2.5rem; /* mt-10 = 2.5rem for buttons */
    letter-spacing: -0.01em;
    animation: fade-in 0.5s ease-out 0.25s backwards;
}

.game-date {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
    margin-top: 1.5rem; /* mt-6 to match home page */
    margin-bottom: 1.5rem; /* Add bottom spacing */
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
    text-align: center;
    color: #d1d5db;
}

/* ===========================
   Footer
   =========================== */

.footer {
    position: absolute;
    bottom: 1.5rem; /* bottom-6 = 1.5rem */
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.875rem; /* text-sm = 0.875rem */
    color: var(--muted);
    animation: fade-in 0.5s ease-out 0.35s backwards;
}

.footer a {
    color: var(--muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer a:hover {
    color: var(--foreground);
}

/* ===========================
   CTA Button Container
   =========================== */

.cta-buttons {
    margin-top: 2.5rem; /* mt-10 = 2.5rem */
    display: flex;
    flex-direction: column;
    gap: 1rem; /* gap-4 = 1rem */
    align-items: center; /* Center buttons within container */
}

/* ===========================
   Buttons
   =========================== */

.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease-out;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: var(--shadow-soft);
    animation: fade-in 0.5s ease-out 0.3s backwards;
}

.btn-primary:hover:not(:disabled) {
    background: hsl(161, 93%, 27%);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
    box-shadow: var(--shadow-soft);
    animation: fade-in 0.5s ease-out 0.35s backwards;
}

.btn-secondary:hover:not(:disabled) {
    background: hsl(0, 0%, 28%);
}

.btn-small {
    font-size: 0.875rem; /* text-sm */
    padding: 0.375rem 0.75rem; /* Small padding */
    border-radius: 0.375rem; /* rounded-md */
    font-weight: 500; /* font-medium */
}

.btn-ghost {
    background: transparent;
    color: var(--foreground);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-ghost:hover:not(:disabled) {
    background: hsl(0, 0%, 92%);
}

.btn-ghost:active {
    background: hsl(0, 0%, 88%);
}

.btn-icon {
    display: inline-block;
    width: 1rem; /* h-4 w-4 = 16px */
    height: 1rem;
    margin-right: 0.375rem; /* gap-1.5 */
    vertical-align: middle;
}

.btn-large {
    font-size: 1.125rem; /* text-lg = 1.125rem */
    padding: 0 2.5rem; /* px-10 = 2.5rem */
    width: 100%;
    margin-bottom: 1rem; /* gap-4 = 1rem */
    border-radius: 0.75rem; /* rounded-xl = 0.75rem */
    height: 3.5rem; /* h-14 = 3.5rem */
}

/* Retro Buttons */
.btn-retro {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 1rem 2rem !important;
    border-radius: 0.75rem;
    border: 2px solid var(--foreground) !important;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white !important;
    box-shadow: 4px 4px 0px 0px var(--foreground) !important;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-retro.btn-primary {
    background: var(--primary) !important;
}

.btn-retro.btn-secondary {
    background: var(--secondary) !important;
}

.btn-retro:hover:not(:active) {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px 0px var(--foreground) !important;
}

.btn-retro:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px 0px var(--foreground) !important;
}

/* Remove the old shadow/content div styles - now handled directly on button */
.btn-shadow {
    display: none;
}

.btn-content {
    /* Content is now directly in the button */
}

.btn-icon {
    color: #facc15; /* yellow-400 for trophy */
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ===========================
   Menu Sections
   =========================== */

.menu-section {
    margin-bottom: var(--spacing-lg);
}

.grid-size-buttons,
.mode-buttons {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

.grid-size-buttons .btn {
    flex: 1;
    max-width: 150px;
}

.grid-size-buttons .btn:hover:not(.selected) {
    background: linear-gradient(135deg, #8b7355 0%, #6a5d51 50%, #8b7355 100%);
    border-color: #9d8569;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.grid-size-buttons .btn.selected {
    background: linear-gradient(135deg, var(--btn-primary) 0%, #7a5d3d 50%, var(--btn-primary) 100%);
    border-color: #d4a574;
    box-shadow: 0 0 0 3px rgba(180, 137, 94, 0.5);
    transform: scale(1.05);
}

.mode-buttons .btn-mode {
    flex: 1;
    padding: var(--spacing-md);
    background-color: var(--tile-grey);
    text-align: center;
    color: var(--text-white);
    border: 2px solid #5a4d41;
    border-radius: 8px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.mode-buttons .btn-mode:hover:not(.selected) {
    background: linear-gradient(135deg, #8b7355 0%, #6a5d51 50%, #8b7355 100%);
    border-color: #9d8569;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.mode-buttons .btn-mode strong {
    color: var(--text-white);
}

.mode-buttons .btn-mode small {
    color: rgba(255, 255, 255, 0.85);
}

.mode-buttons .btn-mode.selected {
    background: linear-gradient(135deg, var(--btn-primary) 0%, #7a5d3d 50%, var(--btn-primary) 100%);
    border-color: #d4a574;
    box-shadow: 0 0 0 3px rgba(180, 137, 94, 0.5);
    transform: scale(1.05);
}

.lock-icon {
    margin-left: var(--spacing-xs);
}

/* ===========================
   HUD (Heads-Up Display)
   =========================== */

.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding: 0.5rem 1rem; /* py-2 px-4 */
    background-color: hsl(0, 0%, 98%); /* bg-card - off-white */
    border-radius: 9999px; /* rounded-full - pill shape */
    box-shadow: var(--shadow-soft);
    gap: 1rem; /* gap-4 */
}

.stats {
    display: flex;
    gap: 1.5rem; /* gap-6 - wider spacing */
    align-items: center;
}

.stat {
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    color: var(--foreground);
}

.stat span {
    color: var(--foreground);
}

/* ===========================
   Progress Helper (Word Chips)
   =========================== */

.progress-helper {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    justify-content: center;
    margin-bottom: var(--spacing-md);
    min-height: 40px;
    padding: var(--spacing-xs);
}

.word-chip {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition-fast);
    animation: chipAppear var(--transition-normal);
    color: white;
    box-shadow: var(--shadow-soft);
}

/* V3: Colored word chips */
.word-chip-green {
    background-color: #10b981; /* Emerald-500 */
}

.word-chip-blue {
    background-color: #3b82f6; /* Blue-500 */
}

.word-chip-orange {
    background-color: #f97316; /* Orange-500 */
}

.word-chip-purple {
    background-color: #a855f7; /* Purple-500 */
}

/* V3: Glow effect when solved */
.word-chip.solved {
    animation: chipGlow 1.5s ease-in-out infinite;
}

@keyframes chipGlow {
    0%, 100% {
        box-shadow: 0 0 10px currentColor, var(--shadow-soft);
    }
    50% {
        box-shadow: 0 0 20px currentColor, 0 0 30px currentColor, var(--shadow-soft);
    }
}

@keyframes chipAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Win Message in Progress Helper Area */
.progress-helper.win-message {
    flex-direction: column;
    align-items: center;
    background: var(--background);
    border: 4px solid var(--foreground);
    border-radius: 12px;
    padding: var(--spacing-md);
    min-height: auto;
    animation: slideDown var(--transition-normal);
    box-shadow: 6px 6px 0px 0px var(--foreground);
}

.win-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 var(--spacing-xs) 0;
    color: var(--foreground);
}

.win-name-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0 0 var(--spacing-md) 0;
    width: 100%;
    max-width: 20rem;
}

.win-name-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    text-align: left;
}

.win-name-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.win-name-input {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border: 3px solid var(--foreground);
    border-radius: 0.5rem;
    background: white;
    color: var(--foreground);
    width: 100%;
    text-align: center;
    box-shadow: 3px 3px 0px 0px var(--foreground);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
    caret-color: transparent;
}

.win-name-input:focus {
    outline: none;
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0px 0px var(--foreground);
}

/* Terminal-style cursor */
.terminal-cursor {
    position: absolute;
    pointer-events: none;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--foreground);
    animation: blink-cursor 1s step-end infinite;
}

.win-name-input:not(:focus) ~ .terminal-cursor {
    display: none;
}

@keyframes blink-cursor {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

.win-name-input::placeholder {
    color: var(--muted);
    font-size: 0.875rem;
}

.win-buttons-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    width: 100%;
    max-width: 30rem;
}

.win-buttons-row {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

.win-buttons-row .btn {
    flex: 1;
    font-size: 0.875rem;
    padding: var(--spacing-xs) var(--spacing-md);
}

.win-name-input {
    width: 100%;
    margin-bottom: var(--spacing-md);
}

.win-name-input input {
    width: 100%;
    max-width: 300px;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    font-family: 'Roboto Mono', monospace;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    transition: all var(--transition-fast);
}

.win-name-input input:focus {
    outline: none;
    border-color: var(--text-white);
    background: rgba(255, 255, 255, 0.2);
}

.win-name-input input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* ===========================
   Leaderboard Screen
   =========================== */

.leaderboard-container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto var(--spacing-xl) auto;
    padding: 0 var(--spacing-sm); /* Add horizontal padding for mobile */
    overflow-x: hidden;
    box-sizing: border-box; /* Include padding in width calculation */
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 60px 1fr 100px 80px;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lb-col-position,
.lb-col-player {
    text-align: left;
}

.lb-col-time,
.lb-col-moves {
    text-align: right;
}

.leaderboard-list {
    max-height: 50vh;
    overflow-y: auto;
    padding: var(--spacing-xs) 0;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 60px 1fr 100px 80px;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: 0.25rem;
    background: white;
    border-radius: 8px;
    transition: all var(--transition-fast);
    color: var(--foreground);
}

.leaderboard-entry:hover {
    background: hsl(0, 0%, 96%);
}

.lb-position {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    font-size: 1rem;
}

.lb-medal {
    font-size: 1.25rem;
    min-width: 24px;
}

.lb-number {
    color: var(--muted);
}

.lb-player {
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--foreground);
}

.lb-time {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    text-align: right;
}

.lb-moves {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    text-align: right;
}

.empty-leaderboard {
    text-align: center;
    padding: var(--spacing-xl);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.125rem;
}

/* ===========================
   Shared Result Screen
   =========================== */

.shared-result-content {
    max-width: 500px;
    margin: 0 auto var(--spacing-lg);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, rgba(55, 65, 81, 0.6) 0%, rgba(31, 41, 55, 0.6) 100%);
    border-radius: 12px;
}

.shared-result-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.result-player {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.result-badge {
    display: inline-block;
    background-color: var(--btn-primary);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 8px;
    font-size: 0.875rem;
    text-transform: uppercase;
}

.shared-result-stats {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.result-stat {
    font-size: 1.125rem;
    font-weight: 700;
}

.shared-result-words {
    text-align: center;
}

.shared-result-words h3 {
    margin-bottom: var(--spacing-md);
    color: var(--text-white);
}

.words-display {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    justify-content: center;
}

.shared-result-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* ===========================
   Game Grid
   =========================== */

.game-grid {
    display: grid;
    gap: 0.5rem; /* gap-2 = 0.5rem */
    max-width: fit-content;
    margin: 0 auto var(--spacing-lg);
    padding: 1rem; /* p-4 = 1rem */
    background: hsl(20, 25%, 20%); /* Dark brown game board */
    border-radius: 1rem; /* rounded-2xl */
    border: none;
    box-shadow: var(--shadow-elevated);
    touch-action: none;
    user-select: none;
}

.game-grid.size-4 {
    grid-template-columns: repeat(4, 1fr);
}

.game-grid.size-5 {
    grid-template-columns: repeat(5, 1fr);
}

.tile {
    aspect-ratio: 1;
    width: 4rem; /* h-16 w-16 = 4rem (64px) */
    height: 4rem;
    background: hsl(0, 0%, 98%); /* bg-card - off-white */
    color: var(--foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-tile);
    font-size: 1.5rem; /* text-2xl = 1.5rem (24px) */
    font-weight: 700;
    border-radius: 0.375rem; /* rounded-md */
    transition: all var(--transition-fast);
    cursor: grab;
    position: relative;
    border: none;
    box-shadow: var(--shadow-soft);
}

.tile:active {
    cursor: grabbing;
    transform: scale(0.95);
}

/* V3: Colored Tiles */
.tile-green {
    background: #10b981 !important; /* Emerald-500 */
    color: white !important;
}

.tile-blue {
    background: #3b82f6 !important; /* Blue-500 */
    color: white !important;
}

.tile-orange {
    background: #f97316 !important; /* Orange-500 */
    color: white !important;
}

.tile-purple {
    background: #a855f7 !important; /* Purple-500 */
    color: white !important;
}

/* V3: Row correct state - subtle glow effect */
.tile.row-correct {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5), var(--shadow-soft);
    animation: tilePulse 0.5s ease-out;
}

@keyframes tilePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Grid Row/Column States */
.tile.correct {
    background: var(--success-green);
    color: white;
    box-shadow: var(--shadow-soft);
    animation: pulse 0.3s ease-out;
}

.tile.partial {
    background: hsl(0, 0%, 92%);
    color: var(--foreground);
    box-shadow: var(--shadow-soft);
}

/* Pulse Animation */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===========================
   Instructions
   =========================== */

.instructions {
    text-align: center;
    font-size: 0.875rem;
    color: #9ca3af;
    line-height: 1.6;
}

.instructions p {
    margin-bottom: var(--spacing-xs);
}

/* ===========================
   Win Screen
   =========================== */

.win-stats {
    text-align: center;
    font-size: 1.5rem;
    margin: var(--spacing-lg) 0;
}

.win-stats p {
    margin-bottom: var(--spacing-sm);
}

.win-stats span {
    color: var(--success-green);
    font-weight: 700;
}

/* ===========================
   How to Play Button
   =========================== */

/* Help Button - Updated for Material Icons */
.btn-help {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--foreground);
    box-shadow: 4px 4px 0px 0px var(--foreground);
    transition: all var(--transition-fast);
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 20;
    cursor: pointer;
}

.btn-help:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px 0px var(--foreground);
}

.btn-help .material-icons {
    font-size: 1.5rem;
    transition: transform var(--transition-fast);
}

.btn-help:hover .material-icons {
    transform: rotate(12deg);
}

/* ===========================
   Modals (How to Play & Win)
   =========================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    overflow-y: auto;
    animation: fadeIn var(--transition-normal);
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

/* Mobile: Align modals to top so keyboard doesn't cover input */
@media (max-width: 768px) {
    .modal {
        align-items: flex-start;
        padding-top: 2rem;
    }
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #ffffff;
    border: 4px solid var(--foreground);
    border-radius: 16px;
    box-shadow: 8px 8px 0px 0px var(--foreground);
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideDown var(--transition-normal);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: none;
    color: var(--foreground);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--primary);
    transform: rotate(90deg) scale(1.1);
}

.modal-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 3px solid var(--foreground);
}

.modal-header .game-title {
    font-size: 3rem;
    margin-bottom: 0;
    color: var(--foreground);
}

.modal-header .game-title-daily {
    font-size: 2.5rem;
    margin-top: 0.25rem;
    color: var(--primary) !important;
}

.modal-subtitle {
    font-size: 1.1rem;
    color: var(--muted);
    margin-top: var(--spacing-sm);
    margin-bottom: 0;
    font-weight: 500;
}

.modal-content h2 {
    margin-bottom: var(--spacing-lg);
    color: var(--foreground);
    font-size: 2rem;
}

.modal-content h3 {
    color: var(--foreground);
    font-size: 1.3rem;
    margin-bottom: var(--spacing-md);
    font-weight: 700;
}

.instructions-section {
    margin-bottom: var(--spacing-lg);
    background: #f8f9fa;
    padding: var(--spacing-md);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

/* Win Modal - Simple Arcade Style */
.win-modal-content {
    max-width: 400px;
    text-align: center;
    background: var(--background);
    border: 4px solid var(--foreground);
    box-shadow: 8px 8px 0px 0px var(--foreground);
}

.win-modal-header {
    background: var(--primary);
    margin: calc(-1 * var(--spacing-xl));
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    border-bottom: 3px solid var(--foreground);
}

.win-modal-header .win-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
    margin: 0;
}

.win-modal-body {
    padding: var(--spacing-md);
}

.instructions-section p {
    line-height: 1.7;
    color: var(--foreground);
    margin-bottom: var(--spacing-sm);
    font-size: 1rem;
}

.instructions-section ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.instructions-section ul li {
    line-height: 1.9;
    color: var(--foreground);
    padding-left: var(--spacing-md);
    position: relative;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.instructions-section ul li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.instructions-section strong {
    color: var(--foreground);
    font-weight: 700;
}

.color-indicator {
    font-weight: 700;
}

.color-indicator.green {
    color: var(--success-green);
}

.color-indicator.orange {
    color: var(--partial-orange);
}

.color-indicator.gray {
    color: var(--tile-grey);
}

#gotItBtn {
    margin-top: var(--spacing-md);
}

/* ===========================
   Responsive Design
   =========================== */

/* Mobile Responsive for Retro Design */
@media (max-width: 640px) {
    .game-title {
        font-size: 3rem;
    }

    .title-stroke {
        top: 2px;
        left: 2px;
    }

    .game-title-daily {
        font-size: 2.5rem;
    }

    .game-subtitle {
        font-size: 0.75rem;
    }

    .blob-yellow {
        width: 102px;
        height: 102px;
        top: -40px;
        left: -60px;
    }

    .blob-cyan {
        width: 153px;
        height: 153px;
        bottom: -40px;
        right: -60px;
    }

    .btn-help {
        top: auto;
        bottom: var(--spacing-md);
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }

    .tile {
        font-size: 1.5rem;
    }

    .hud {
        padding: 0.375rem 0.75rem;
        gap: 0.5rem;
        margin-bottom: var(--spacing-md);
    }

    .stats {
        gap: 0.75rem;
        font-size: 0.75rem;
    }

    .stat {
        font-size: 0.75rem;
    }

    #resetBtn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    #resetBtn .btn-icon {
        width: 12px;
        height: 12px;
    }

    /* Leaderboard: Hide moves column on mobile portrait to save space */
    .leaderboard-header {
        grid-template-columns: 45px 1fr 75px; /* 3 columns: rank, name, time */
        padding: var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .leaderboard-entry {
        grid-template-columns: 45px 1fr 75px; /* 3 columns: rank, name, time */
        padding: var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .lb-col-moves,
    .lb-moves {
        display: none; /* Hide moves column on mobile */
    }

    .lb-player {
        min-width: 0; /* Allow text truncation */
        font-size: 0.9rem; /* Slightly smaller on mobile */
    }

    .lb-time {
        font-size: 0.85rem;
    }

    .lb-position {
        font-size: 0.85rem;
    }
}

@media (max-width: 400px) {
    .tile {
        font-size: 1.25rem;
    }

    .mode-buttons {
        flex-direction: column;
    }
}

/* ===========================
   Animations & Transitions
   =========================== */

.tile-sliding {
    transition: transform var(--transition-fast);
}

/* Fade animations */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade + Slide transitions */
@keyframes slideInFade {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutFade {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

.screen {
    /* No default animation - will be triggered by JS */
}

.screen.slide-in {
    animation: slideInFade 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.screen.slide-out {
    animation: slideOutFade 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===========================
   Utility Classes for JS
   =========================== */

.hidden {
    display: none !important;
}

.visible {
    display: flex !important;
}

.visible-block {
    display: block !important;
}
