/* ═══════════════════════════════════════════════════════════════
   LEXI GRID - Game Styles
   File: %OneDrive%\CODING\APPS\StudyNFun\StudyNFun_Hub\lexigrid\lexigrid.css
   Theme: Study’N Fun dark space + study-blue / violet neon accents
   Layout rule: Flexbox/Grid only (overlay stacking via grid-area 1/1)
   ═══════════════════════════════════════════════════════════════ */

:root {
    --standard-spacing: 20px;
    --lxg-accent: #6EC1FF;
    --lxg-accent-2: #C299FF;
    --lxg-correct: #3DDC97;
    --lxg-present: #FFCB6B;
    --lxg-absent: #3A4258;
    --lxg-fail: #FF7A7A;
    --lxg-glass-bg: rgba(3, 7, 18, 0.2);
    --lxg-panel-bg: rgba(3, 7, 18, 0.55);
    --lxg-border: rgba(110, 193, 255, 0.35);
    --lxg-text: #EEF6FF;
    --lxg-text-dim: rgba(238, 246, 255, 0.65);
    --honey: #fbbf24;
    --lxg-tile: 58px;
}

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

body {
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #0E1A33 0%, #070C1C 55%, #030712 100%);
    color: var(--lxg-text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
}

/* Background animation canvases (hub pattern) */
.stars, .fireflies, .fireflies-front {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

.stars { z-index: 0; }
.fireflies { z-index: 1; }
.fireflies-front { z-index: 2; }

.lxg-page {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 840px;
    display: flex;
    flex-direction: column;
    gap: var(--standard-spacing);
    padding: var(--standard-spacing);
}

/* Top navigation (hub pattern) */
.lxg-top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(15, 15, 40, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.home-btn {
    background: rgba(15, 15, 40, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-btn:hover {
    background: rgba(110, 193, 255, 0.2);
    box-shadow: 0 2px 8px rgba(110, 193, 255, 0.3);
}

.home-icon {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s ease;
}

.home-btn:hover .home-icon { color: var(--lxg-accent); }

.lxg-sound-btn {
    background: rgba(15, 15, 40, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lxg-sound-btn:hover { background: rgba(110, 193, 255, 0.2); }

.lxg-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lxg-title {
    font-size: 2.2rem;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--lxg-accent), var(--lxg-accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lxg-subtitle {
    color: var(--lxg-text-dim);
    font-size: 0.95rem;
}

.lxg-main {
    display: flex;
    flex-direction: column;
    gap: var(--standard-spacing);
}

/* Stage: game + overlays stacked in the SAME grid cell */
.lxg-stage {
    display: grid;
    border: 1px solid var(--lxg-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--lxg-glass-bg);
    backdrop-filter: blur(4px);
}

.lxg-stage > * { grid-area: 1 / 1; }

.lxg-fs-btn {
    justify-self: end;
    align-self: start;
    z-index: 3;
    margin: 10px;
    background: rgba(15, 15, 40, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--lxg-text);
    font-size: 1.1rem;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lxg-fs-btn:hover { background: rgba(110, 193, 255, 0.25); }

.lxg-stage:fullscreen {
    border: none;
    border-radius: 0;
    background: #030712;
    overflow-y: auto;
}

.lxg-stage.fs-fallback {
    position: fixed;
    inset: 0;
    z-index: 999;
    border: none;
    border-radius: 0;
    background: #030712;
    overflow-y: auto;
}

/* Game area */
.lxg-game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 18px;
}

.lxg-stage:fullscreen .lxg-game,
.lxg-stage.fs-fallback .lxg-game {
    justify-content: center;
    min-height: 100%;
}

.lxg-hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding-right: 56px; /* fullscreen butonuyla çakışmasın */
}

.lxg-hud-level {
    color: var(--lxg-accent);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.lxg-hud-word {
    color: var(--lxg-text-dim);
    font-size: 0.85rem;
}

.lxg-hud-lives {
    color: var(--lxg-fail);
    font-size: 1rem;
    letter-spacing: 3px;
}

.lxg-hud-lives .lost { color: rgba(238, 246, 255, 0.18); }

.lxg-hud-score {
    color: var(--lxg-accent-2);
    font-size: 1.3rem;
}

.lxg-hidden { display: none !important; }

/* Timer (6 and 7 letter levels) */
.lxg-timer {
    width: min(100%, 420px);
    display: flex;
    align-items: center;
    gap: 12px;
}

.lxg-timer-text {
    min-width: 48px;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--lxg-accent);
    font-variant-numeric: tabular-nums;
}

.lxg-timer-track {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.lxg-timer-bar {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--lxg-accent), var(--lxg-accent-2));
    transition: width 0.25s linear;
}

.lxg-timer.warn .lxg-timer-text { color: var(--lxg-present); }
.lxg-timer.warn .lxg-timer-bar { background: var(--lxg-present); }
.lxg-timer.danger .lxg-timer-text { color: var(--lxg-fail); animation: lxgPulse 0.8s ease-in-out infinite alternate; }
.lxg-timer.danger .lxg-timer-bar { background: var(--lxg-fail); }

@keyframes lxgPulse {
    from { opacity: 1; }
    to   { opacity: 0.45; }
}

/* ---------- Board ---------- */
.lxg-board {
    display: grid;
    gap: 7px;
}

.lxg-row {
    display: grid;
    grid-template-columns: repeat(var(--lxg-cols-n, 5), var(--lxg-tile));
    gap: 7px;
}

.lxg-tile {
    width: var(--lxg-tile);
    height: var(--lxg-tile);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(110, 193, 255, 0.22);
    border-radius: 8px;
    background: rgba(3, 7, 18, 0.45);
    color: var(--lxg-text);
    font-size: 1.7rem;
    font-weight: 800;
    text-transform: uppercase;
    -webkit-user-select: none;
    user-select: none;
}

.lxg-tile.filled {
    border-color: rgba(110, 193, 255, 0.7);
    animation: lxgPop 0.12s ease-out;
}

@keyframes lxgPop {
    0%   { transform: scale(0.88); }
    60%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.lxg-tile.correct {
    background: var(--lxg-correct);
    border-color: var(--lxg-correct);
    color: #04140C;
    box-shadow: 0 0 14px rgba(61, 220, 151, 0.45);
}

.lxg-tile.present {
    background: var(--lxg-present);
    border-color: var(--lxg-present);
    color: #1C1200;
    box-shadow: 0 0 14px rgba(255, 203, 107, 0.4);
}

.lxg-tile.absent {
    background: var(--lxg-absent);
    border-color: var(--lxg-absent);
    color: rgba(238, 246, 255, 0.75);
}

/* reveal: each tile flips on its X axis; JS sets the colour at the halfway point */
.lxg-tile.flip { animation: lxgFlip 0.45s ease-in-out; }

@keyframes lxgFlip {
    0%   { transform: rotateX(0deg); }
    50%  { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

/* rejected guess: the row shakes */
.lxg-row.shake { animation: lxgShake 0.45s ease-in-out; }

@keyframes lxgShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-8px); }
    30% { transform: translateX(7px); }
    45% { transform: translateX(-5px); }
    60% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

/* solved: winning row hops in a wave (--i set per tile in JS) */
.lxg-row.win .lxg-tile {
    animation: lxgHop 0.5s ease-out both;
    animation-delay: calc(var(--i, 0) * 90ms);
}

@keyframes lxgHop {
    0%, 100% { transform: translateY(0); }
    45% { transform: translateY(-16px); }
}

/* whole game area: glow on success, red flash on fail */
.lxg-game.win-flash { animation: lxgWinFlash 1.2s ease-out; }

@keyframes lxgWinFlash {
    0%   { box-shadow: inset 0 0 0 rgba(61, 220, 151, 0); }
    30%  { box-shadow: inset 0 0 90px rgba(61, 220, 151, 0.4); }
    100% { box-shadow: inset 0 0 0 rgba(61, 220, 151, 0); }
}

.lxg-game.fail-flash { animation: lxgFailFlash 1s ease-out; }

@keyframes lxgFailFlash {
    0%   { box-shadow: inset 0 0 0 rgba(255, 70, 70, 0); }
    20%  { box-shadow: inset 0 0 110px rgba(255, 70, 70, 0.5); }
    100% { box-shadow: inset 0 0 0 rgba(255, 70, 70, 0); }
}

.lxg-msg {
    min-height: 1.4em;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--lxg-present);
    text-align: center;
}

.lxg-msg.good { color: var(--lxg-correct); }
.lxg-msg.bad { color: var(--lxg-fail); }

/* ---------- On-screen keyboard ---------- */
.lxg-keyboard {
    width: min(100%, 540px);
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.lxg-kb-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.lxg-key {
    flex: 1 1 0;
    max-width: 46px;
    height: 52px;
    border-radius: 7px;
    border: 1px solid var(--lxg-border);
    background: rgba(3, 7, 18, 0.55);
    color: var(--lxg-text);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.lxg-key-wide {
    flex: 1.6 1 0;
    max-width: 76px;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.lxg-key:hover { background: rgba(110, 193, 255, 0.2); transform: translateY(-1px); }

.lxg-key.correct { background: var(--lxg-correct); border-color: var(--lxg-correct); color: #04140C; }
.lxg-key.present { background: var(--lxg-present); border-color: var(--lxg-present); color: #1C1200; }
.lxg-key.absent  { background: var(--lxg-absent); border-color: var(--lxg-absent); color: rgba(238, 246, 255, 0.45); }

/* ---------- Overlays (GAME PANEL STANDARD v2, Lexi Grid copy) ---------- */
.lxg-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 7, 18, 0.72);
    z-index: 4;
    padding: 16px;
}

.lxg-overlay-help { z-index: 5; }

.lxg-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: var(--lxg-panel-bg);
    border: 1px solid var(--lxg-border);
    border-radius: 12px;
    padding: 26px 30px;
    width: min(94%, 400px);
    text-align: center;
    box-shadow: 0 0 40px rgba(110, 193, 255, 0.12);
}

.lxg-card-wide {
    width: min(94%, 540px);
    background: rgba(3, 7, 18, 0.92); /* the grid behind must not bleed through the meaning card */
    backdrop-filter: blur(6px);
}

.lxg-card-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--lxg-accent);
}

h1.lxg-card-title {
    font-size: 2rem;
    letter-spacing: 5px;
    background: linear-gradient(90deg, var(--lxg-accent), var(--lxg-accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lxg-card-title.lxg-title-win { color: var(--lxg-correct); }
.lxg-card-title.lxg-title-fail { color: var(--lxg-fail); }

.lxg-tag {
    font-size: 0.85rem;
    color: var(--lxg-text-dim);
}

.lxg-final {
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: var(--lxg-text-dim);
}

.lxg-final b { color: var(--lxg-accent); }

.lxg-label {
    align-self: stretch;
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: var(--lxg-text-dim);
    text-transform: uppercase;
    text-align: left;
}

.lxg-label-center { text-align: center; margin-top: 2px; }

.lxg-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--lxg-border);
    background: rgba(3, 7, 18, 0.6);
    color: var(--lxg-text);
    font-size: 1rem;
    text-align: center;
    outline: none;
}

.lxg-input:focus { border-color: var(--lxg-accent); }

.lxg-error {
    color: #FF8A8A;
    font-size: 0.8rem;
    min-height: 1em;
}

.lxg-pick-group {
    align-self: stretch;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.lxg-pick-btn {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--lxg-border);
    background: rgba(3, 7, 18, 0.5);
    color: var(--lxg-text-dim);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.lxg-pick-sub {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--lxg-present);
}

.lxg-pick-btn.active {
    background: rgba(110, 193, 255, 0.22);
    border-color: var(--lxg-accent);
    color: var(--lxg-accent);
}

.lxg-btn-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.lxg-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--lxg-accent), var(--lxg-accent-2));
    color: #050B1A;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.lxg-btn:hover { filter: brightness(1.15); }

.lxg-btn-secondary {
    padding: 12px 22px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--lxg-border);
    color: var(--lxg-text-dim);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
}

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

.lxg-help {
    font-size: 0.72rem;
    letter-spacing: .5px;
    color: var(--lxg-text-dim);
    opacity: .8;
}

body.touch .lxg-help { display: none; }

.lxg-kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--lxg-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: rgba(3, 7, 18, 0.6);
    color: var(--lxg-text);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
}

button.lxg-kbd { cursor: pointer; }
button.lxg-kbd:hover { border-color: var(--lxg-accent); color: var(--lxg-accent); }

/* ---------- Meaning card (round + game over) ---------- */
.lxg-wordcard {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: left;
    background: rgba(3, 7, 18, 0.45);
    border: 1px solid var(--lxg-border);
    border-radius: 10px;
    padding: 14px 16px;
}

.lxg-wc-tiles {
    display: flex;
    gap: 5px;
}

.lxg-tile-mini {
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
    border-radius: 6px;
}

.lxg-wc-def {
    align-self: stretch;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--lxg-text);
}

.lxg-wc-pos {
    color: var(--lxg-accent-2);
    font-size: 0.8rem;
    font-style: italic;
    margin-right: 6px;
}

.lxg-wc-ex {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.lxg-wc-ex-label {
    font-size: 0.68rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--lxg-present);
}

.lxg-wc-ex-text {
    font-size: 0.9rem;
    line-height: 1.5;
    font-style: italic;
    color: var(--lxg-text-dim);
}

.lxg-wc-ex-text b {
    font-style: normal;
    color: var(--lxg-correct);
}

.lxg-final-score {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--lxg-accent-2);
}

.lxg-submit-status {
    font-size: 0.9rem;
    color: var(--lxg-text-dim);
    min-height: 1.2em;
}

/* ---------- CONTROLS (F1) ---------- */
.lxg-keys {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.lxg-keygroup h3 {
    margin-bottom: 6px;
    font-size: 0.72rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--lxg-accent-2);
}

.lxg-keylist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.lxg-keylist li {
    display: flex;
    align-items: center;
    gap: 14px;
}

.lxg-keypair {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 150px;
}

.lxg-keysep {
    font-size: 0.8rem;
    color: var(--lxg-text-dim);
}

.lxg-cap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--lxg-border);
    border-bottom-width: 3px;
    border-radius: 7px;
    background: linear-gradient(180deg, rgba(110, 193, 255, 0.14), rgba(3, 7, 18, 0.6));
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
    color: var(--lxg-text);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.lxg-cap-wide { min-width: 62px; }

.lxg-keydesc {
    font-size: 0.85rem;
    color: var(--lxg-text-dim);
}

/* ---------- Leaderboard ---------- */
.lxg-board-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lxg-board-title {
    font-size: 1.2rem;
    color: var(--lxg-accent);
    letter-spacing: 1px;
}

.lxg-board-week {
    font-size: 0.85rem;
    color: var(--lxg-text-dim);
    font-weight: 400;
}

.lxg-board-container {
    background: var(--lxg-glass-bg);
    backdrop-filter: blur(4px);
    border: 1px solid var(--lxg-border);
    border-radius: 12px;
    padding: var(--standard-spacing);
}

.lxg-board-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    counter-reset: rank;
}

.lxg-board-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(110, 193, 255, 0.06);
    counter-increment: rank;
}

.lxg-board-list li::before {
    content: counter(rank);
    font-weight: 700;
    color: var(--lxg-accent);
    min-width: 24px;
    text-align: right;
}

.lxg-board-list li.lxg-board-top1 {
    background: rgba(255, 209, 107, 0.12);
    border: 1px solid rgba(255, 209, 107, 0.45);
}

.lxg-board-list li.lxg-board-me { border: 1px solid var(--lxg-accent-2); }

.lxg-board-nick {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lxg-board-score {
    font-weight: 700;
    color: var(--lxg-accent-2);
}

.lxg-board-loading,
.lxg-board-empty {
    color: var(--lxg-text-dim);
    justify-content: center;
}

.lxg-board-list li.lxg-board-loading::before,
.lxg-board-list li.lxg-board-empty::before {
    content: '';
    min-width: 0;
}

.lxg-board-note {
    font-size: 0.8rem;
    color: var(--lxg-text-dim);
    text-align: center;
}

/* Footer (site standard: honey copyright) */
.lxg-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: var(--standard-spacing);
}

.lxg-copyright {
    color: var(--honey);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
    :root { --lxg-tile: min(50px, calc((100vw - 110px) / var(--lxg-cols-n, 5))); }

    .lxg-title { font-size: 1.6rem; }
    .lxg-game { padding: 14px 8px; gap: 10px; }
    .lxg-tile { font-size: 1.35rem; }
    .lxg-board, .lxg-row { gap: 5px; }
    .lxg-card { padding: 18px; gap: 9px; }
    .lxg-final-score { font-size: 2rem; }
    .lxg-key { height: 48px; font-size: 0.9rem; }
    .lxg-kb-row { gap: 4px; }
    .lxg-keypair { min-width: 118px; }
    .lxg-cap-wide { min-width: 50px; }
    .lxg-pick-btn { padding: 8px 4px; font-size: 0.78rem; letter-spacing: 0.5px; }
    .lxg-card-wide { padding: 16px 12px; }
}

@media (max-height: 760px) and (min-width: 768px) {
    :root { --lxg-tile: 50px; }
    .lxg-key { height: 46px; }
}
