/* Hardle16 - Design System */


:root {
    /* Colors */
    --bg-color: #1a1a1c;
    --text-color: #ffffff;
    --key-bg: #58585a;
    --key-text: #d1d1d3;
    --absent: #121213;
    --present: #c2ae5a;
    --correct: #649866;
    --border: #404042;
    --accent: #6bb1f8;
    --win-bg: #1a2e1c;
    --loss-bg: #2e1a1a;
    --loss-red: #e66;
    --error: #a72e2e;
    --tile-toggled: #565758;

    /* Saturated Pastels Palette */
    --pastel-1: hsl(4, 100%, 78%);
    --pastel-2: hsl(24, 100%, 80%);
    --pastel-3: hsl(83, 75%, 78%);
    --pastel-4: hsl(159, 83%, 75%);
    --pastel-5: hsl(231, 73%, 80%);
    --pastel-6: hsl(355, 100%, 75%);
    --pastel-0: hsl(195, 96%, 75%);
    --pastel-7: hsl(298, 88%, 82%);

    /* Daily Theme */
    --bg-top: #1a1a1c;
    --bg-bottom: #000000;

    /* Typography */
    --font-main: 'Outfit', sans-serif;
    --font-title: 'Kirang Haerang', cursive;

    /* Layout */
    --max-main-width: 500px;
    --header-height: 60px;
    --transition-speed: 0.2s;
}

/* --- Global Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

/* --- Particle Effects --- */
.particle {
    position: fixed;
    pointer-events: none;
    z-index: 11000;
    width: 12px;
    height: 12px;
    background-color: var(--correct);
    border-radius: 50%;
    animation: particle-burst 1.2s cubic-bezier(0, 0, 0.2, 1) forwards;
}

.particle.sparkle {
    background-color: white;
    box-shadow: 0 0 8px white;
}

@keyframes particle-burst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* --- Splash Screen --- */
.splash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, var(--bg-top), var(--bg-bottom));
    background-color: var(--bg-bottom);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.splash-overlay.hidden {
    display: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.splash-title {
    font-family: var(--font-title);
    font-size: 5rem;
    font-weight: normal;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    gap: 4px;
}

.animated-letter {
    display: inline-block;
    animation: title-float 3s ease-in-out infinite;
}

/* Pastel Colors */
/* Pastel Colors Mapping */
.animated-letter:nth-child(7n+1) {
    color: var(--pastel-1);
}

.animated-letter:nth-child(7n+2) {
    color: var(--pastel-2);
}

.animated-letter:nth-child(7n+3) {
    color: var(--pastel-3);
}

.animated-letter:nth-child(7n+4) {
    color: var(--pastel-4);
}

.animated-letter:nth-child(7n+5) {
    color: var(--pastel-5);
}

.animated-letter:nth-child(7n+6) {
    color: var(--pastel-6);
}

.animated-letter:nth-child(7n+0) {
    color: var(--pastel-0);
}

@keyframes title-float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
    }

    33% {
        transform: translateY(-3px) rotate(-1.5deg) scale(1.03);
    }

    66% {
        transform: translateY(2px) rotate(1.5deg) scale(0.97);
    }
}

.no-animation {
    animation: none !important;
    transform: none !important;
}

.splash-date {
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: var(--key-text);
    margin-bottom: 40px;
    text-transform: uppercase;
}

.play-btn {
    background-color: var(--correct);
    color: white;
    border: none;
    padding: 16px 48px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 4px;
    transition: transform 0.2s, background-color 0.2s;
    margin-bottom: 20px;
}

.play-btn.disabled {
    background-color: #2a2a2c;
    color: #505052;
    cursor: default;
    pointer-events: none;
    opacity: 0.6;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--key-text);
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    text-transform: uppercase;
    font-family: var(--font-main);
    letter-spacing: 1px;
    margin-top: 20px;
}

.secondary-btn:hover {
    border-color: var(--text-color);
    color: var(--text-color);
}

.play-btn:active {
    transform: scale(0.95);
    background-color: #5a8a5b;
}

.splash-footer {
    font-size: 0.8rem;
    color: var(--key-text);
    letter-spacing: 1px;
    opacity: 0.7;
    margin-top: 20px;
}

.help-text {
    color: var(--text-color);
    margin-bottom: 40px;
    line-height: 1.6;
    opacity: 0.9;
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
}

@media (max-width: 480px) {
    .splash-title {
        font-size: 4.2rem;
        margin-bottom: 0px;
        line-height: 1;
    }

    .splash-number {
        font-size: 1.2rem;
        margin-bottom: 20px;
    }

    .splash-date {
        font-size: 0.9rem;
        margin-bottom: 30px;
    }

    .help-text {
        font-size: 0.8rem;
        margin-bottom: 20px;
    }
}

body {
    background: linear-gradient(to bottom, var(--bg-top), var(--bg-bottom));
    background-color: var(--bg-bottom);
    color: var(--text-color);
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overflow-x: hidden;
    transition: background-color 0.5s ease;
}

body.win-theme {
    background-color: var(--win-bg);
}

body.loss-theme {
    background-color: var(--loss-bg);
}

/* --- Header Component --- */
header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.header-content {
    width: 100%;
    max-width: var(--max-main-width);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
    height: 100%;
}

h1 {
    font-family: var(--font-title);
    font-size: 32px;
    font-weight: normal;
    letter-spacing: 1px;
    white-space: nowrap;
    margin: 0;
    text-transform: uppercase;
    display: flex;
    gap: 2px;
}

.title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    line-height: 1;
}

.header-number {
    font-size: 14px;
    font-family: var(--font-title);
    letter-spacing: 1px;
    color: var(--text-color);
    display: flex;
    gap: 2px;
    white-space: nowrap;
    margin-top: -4px;
    opacity: 0.8;
}

.splash-number,
.help-number {
    font-size: 1.5rem;
    font-family: var(--font-title);
    color: var(--text-color);
    letter-spacing: 1.5px;
    margin-bottom: 4px;
    display: flex;
    justify-content: center;
    gap: 2px;
}

.next-game-timer {
    font-size: 0.9rem;
    color: var(--key-text);
    letter-spacing: 0.5px;
    margin-bottom: 30px;
    opacity: 0.9;
}

.next-game-timer .timer-display {
    font-weight: 700;
    color: var(--text-color);
    font-family: monospace;
    font-size: 1.1rem;
}

#help-overlay .next-game-timer {
    margin-top: 10px;
    margin-bottom: 20px;
}

.header-right {
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#help-btn {
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 24px;
    padding: 4px 10px;
}

/* --- Navigation Component --- */
#boards-nav-container {
    position: sticky;
    top: var(--header-height);
    background: var(--bg-color);
    z-index: 10;
    border-bottom: 1px solid var(--border);
    padding: 8px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    max-width: var(--max-main-width);
    margin: 0 auto;
}

#boards-nav {
    display: flex;
    gap: 4px;
    justify-content: space-between;
    flex: 1;
}

#guess-counter {
    background: var(--key-bg);
    color: var(--key-text);
    padding: 0 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid var(--border);
    white-space: nowrap;
    flex-shrink: 0;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-pair {
    display: flex;
    background: var(--key-bg);
    padding: 1px;
    border-radius: 4px;
    gap: 1px;
    border: 1px solid var(--border);
    flex: 1;
    min-width: 0;
    height: 28px;
    align-items: center;
    transition: border-color 0.2s;
}

.nav-pair.active {
    border: 2px solid var(--accent);
    padding: 0;
}

.nav-pair.active .nav-btn {
    color: white;
}

.nav-btn {
    background: transparent;
    color: var(--key-text);
    border: none;
    border-radius: 2px;
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.nav-btn[data-solved="true"] {
    background: var(--correct);
    color: white;
}

/* --- Game Board Component --- */
main#game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    max-width: var(--max-main-width);
    margin: 0 auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

main#game-container::-webkit-scrollbar {
    display: none;
}

#boards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 12px;
    padding: 16px 8px;
    width: 100%;
}

.grid {
    display: grid;
    grid-template-rows: repeat(21, 1fr);
    grid-gap: 4px;
    width: 100%;
    min-width: 0;
    scroll-margin-top: 130px;
}

.board-label {
    text-align: center;
    font-weight: normal;
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-color);
    font-family: var(--font-title);
    display: flex;
    justify-content: center;
    gap: 2px;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 3px;
}

.tile {
    width: 100%;
    aspect-ratio: 1;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    transition: transform 0.1s ease;
    user-select: none;
}

.tile[data-state="toggled"] {
    border-color: var(--tile-toggled);
}

.tile[data-state="correct"] {
    background-color: var(--correct);
    border-color: var(--correct);
}

.tile[data-state="present"] {
    background-color: var(--present);
    border-color: var(--present);
}

.tile[data-state="absent"] {
    background-color: var(--absent);
    border-color: var(--absent);
}

.tile[data-state="invalid"] {
    background-color: var(--error);
    border-color: var(--error);
}

/* --- Keyboard Component --- */
#keyboard-container {
    position: sticky;
    bottom: 0;
    background: var(--bg-color);
    padding: 8px 4px;
    border-top: 1px solid var(--border);
    z-index: 10;
    width: 100%;
}

#keyboard {
    width: 100%;
    max-width: var(--max-main-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.key-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    touch-action: manipulation;
}

.key {
    background-color: var(--key-bg);
    color: var(--key-text);
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 52px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: opacity 0.1s, background 0.3s;
}

.key:active {
    opacity: 0.6;
}

.key.large {
    flex: 1.5;
    font-size: 12px;
}

.key[data-state="used"] {
    background-color: #464648;
    color: #000000;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5);
    border-color: rgba(0, 0, 0, 0.2);
}

/* --- Modals --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11000;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #121213;
    width: 90%;
    max-width: 400px;
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border);
    position: relative;
    text-align: center;
}

.debug-content {
    max-height: 80vh;
    overflow-y: auto;
}

/* --- Results Screen --- */
.results-content {
    padding: 40px;
}

.result-title {
    font-size: 3.5rem;
    font-family: var(--font-title);
    margin-bottom: 10px;
    letter-spacing: -2px;
    display: flex;
    justify-content: center;
}

.win-theme .result-title {
    color: var(--correct);
}

.win-theme .result-subtitle,
.win-theme .next-game-timer,
.win-theme .next-game-timer .timer-display {
    color: var(--correct);
}

.win-theme .secondary-btn {
    border-color: var(--correct);
    color: var(--correct);
}

.win-theme .secondary-btn:hover {
    background: rgba(100, 152, 102, 0.1);
    border-color: var(--correct);
}

.loss-theme .result-title {
    color: var(--loss-red);
}

.loss-theme .result-subtitle,
.loss-theme .next-game-timer,
.loss-theme .next-game-timer .timer-display {
    color: var(--loss-red);
}

.loss-theme .secondary-btn {
    border-color: var(--loss-red);
    color: var(--loss-red);
}

.loss-theme .secondary-btn:hover {
    background: rgba(238, 102, 102, 0.1);
    /* Keep semi-transparent for now */
    border-color: var(--loss-red);
}

.result-subtitle {
    font-size: 1.1rem;
    color: var(--key-text);
    margin-bottom: 30px;
    font-weight: 500;
}

.debug-controls {
    display: flex;
    gap: 8px;
}

.debug-btn-accent {
    background: var(--accent) !important;
    color: white !important;
    flex: 1;
    font-size: 11px !important;
}

.debug-btn-correct {
    background: var(--correct) !important;
    color: white !important;
    flex: 1;
    font-size: 11px !important;
}

.debug-btn-error {
    background: var(--error) !important;
    color: white !important;
    width: 100%;
    margin-top: 10px;
}

.back-to-title-btn {
    margin-top: 30px !important;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #818384;
    font-size: 24px;
    cursor: pointer;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 20px 0;
}

.stat-val {
    display: block;
    font-size: 28px;
    font-weight: 500;
}

.stat-label {
    font-size: 12px;
}

.footer {
    margin-top: 30px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

#timer {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 10px;
}

#toast-container {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: #ffffff;
    color: #000000;
    padding: 10px 16px;
    border-radius: 4px;
    font-weight: 700;
    animation: fadeInOut 2s ease-in-out forwards;
}

/* --- Animations --- */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

@keyframes reveal {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}


@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }

    10% {
        opacity: 1;
        transform: translateY(0);
    }

    90% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

.reveal {
    animation: reveal 0.2s ease-in-out forwards;
}

/* --- Responsive Adjustments --- */
@media (max-width: 400px) {
    .tile {
        font-size: 1rem;
    }

    h1 {
        font-size: 22px;
    }

    .header-number {
        font-size: 16px;
    }

    .title-group {
        gap: 8px;
    }

    .key {
        height: 48px;
        font-size: 16px;
    }

    .key.large {
        font-size: 11px;
    }

    #boards-container {
        grid-gap: 8px;
        padding: 12px 6px;
    }

    #boards-nav-container {
        padding: 8px 4px;
    }

    .nav-btn {
        font-size: 10px;
    }
}

.splash-date {
    font-family: var(--font-title);
    font-size: 1.5rem;
    margin-bottom: 30px;
    display: flex;
    gap: 2px;
    justify-content: center;
    color: var(--text-color);
}