/* ═══════════════════════════════════════════════════════════════
   LEXIBLOCK - Game Styles
   File: %OneDrive%\CODING\APPS\StudyNFun\StudyNFun_Hub\lexiblock\lexiblock.css
   Theme: Arke tokens (natural colours, 20px spacing) on the hub night sky
   Layout rule: Flexbox/Grid only (overlay stacking via grid-area 1/1)
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #40c4ff;
    --secondary: #00bcd4;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #2196f3;
    --accent: #9c27b0;
    --grey: #b3c2cc;
    --honey: #fbbf24;
    --background: #00000F;
    --surface: rgba(15, 15, 40, 0.3);
    --surface-light: rgba(3, 7, 18, 0.2);
    --panel: rgba(3, 7, 18, 0.9);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-muted: rgba(255, 255, 255, 0.6);
    --border-color: rgba(64, 196, 255, 0.2);
    --border-strong: rgba(64, 196, 255, 0.45);
    --card-radius: 8px;
    --standard-spacing: 20px;
    --container-max-width: 840px;
}

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

html, body {
    background: var(--background);
}

body {
    min-height: 100vh;
    color: var(--text-primary);
    font-family: Arial, sans-serif;
    font-size: 15px;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.stars, .fireflies, .fireflies-front {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    user-select: none;
}

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

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

.lxb-top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.home-btn {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--card-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: background-color 0.15s ease;
}

.home-btn:hover { background: rgba(64, 196, 255, 0.2); }

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

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

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

/* title logo: hub standard sizes 240 / 180 / 135 + accent backglow */
.lxb-title {
    display: flex;
    justify-content: center;
    line-height: 0;
}

.title-img {
    width: 100%;
    max-width: 240px;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(64, 196, 255, .4));
    filter: drop-shadow(0 0 20px color-mix(in srgb, var(--primary) 40%, transparent));
}

/* form controls do not inherit the font by default */
button, input {
    font-family: inherit;
}

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

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

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

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

.lxb-stage:fullscreen,
.lxb-stage.fs-fallback {
    border: none;
    border-radius: 0;
    background: #030712;
}

.lxb-stage.fs-fallback {
    position: fixed;
    inset: 0;
    z-index: 999;
}

/* ---------- Game area ---------- */
.lxb-game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

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

.lxb-hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* HUD tools: music / sound effects / fullscreen */
.lxb-tools {
    display: flex;
    gap: 6px;
}

.lxb-tool {
    width: 34px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 40, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--card-radius);
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.lxb-tool:hover { background: rgba(64, 196, 255, 0.25); }
.lxb-tool.off { opacity: 0.4; text-decoration: line-through; }

/* classic: next piece preview */
.lxb-next {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lxb-next-label {
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.lxb-next canvas {
    display: block;
    border-radius: 4px;
    background: rgba(3, 7, 18, 0.55);
    border: 1px solid var(--border-color);
}

/* speed state next to the level: hold (snowflake) / dropping (arrow) */
.lxb-speed { font-size: 0.8rem; }
.lxb-speed.hold { color: var(--secondary); }
.lxb-speed.down { color: var(--warning); }

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

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

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

.lxb-hud-score {
    color: var(--honey);
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
}

.lxb-progress {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.lxb-progress-bar {
    width: 0;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width 0.3s ease;
}

.lxb-boardwrap {
    display: grid;
    touch-action: none;
}

.lxb-boardwrap > * { grid-area: 1 / 1; }

.lxb-board {
    display: block;
    border-radius: var(--card-radius);
    border: 1px solid var(--border-strong);
    background: rgba(3, 7, 18, 0.55);
    box-shadow: 0 0 30px rgba(64, 196, 255, 0.1);
}

/* stack close to the top: slow red pulse on the board edge */
.lxb-board.danger { animation: lxbDanger 1.1s ease-in-out infinite; }

@keyframes lxbDanger {
    0%, 100% { border-color: rgba(244, 67, 54, 0.45); box-shadow: 0 0 18px rgba(244, 67, 54, 0.2); }
    50% { border-color: rgba(244, 67, 54, 0.95); box-shadow: 0 0 34px rgba(244, 67, 54, 0.5); }
}

.lxb-board.flash-good { animation: lxbGood 0.7s ease-out; }
.lxb-board.flash-bad { animation: lxbBad 0.7s ease-out; }

@keyframes lxbGood {
    0% { box-shadow: 0 0 0 rgba(76, 175, 80, 0); }
    30% { box-shadow: 0 0 40px rgba(76, 175, 80, 0.7); }
    100% { box-shadow: 0 0 30px rgba(64, 196, 255, 0.1); }
}

@keyframes lxbBad {
    0% { box-shadow: 0 0 0 rgba(244, 67, 54, 0); }
    25% { box-shadow: 0 0 46px rgba(244, 67, 54, 0.8); }
    100% { box-shadow: 0 0 30px rgba(64, 196, 255, 0.1); }
}

/* word meaning line: fixed-height row above the board, never covers the play area */
.lxb-msg {
    width: 100%;
    min-height: 1.6em;
    font-size: 0.95rem;
    line-height: 1.6em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.lxb-msg.show { opacity: 1; }

.lxb-msg b {
    color: var(--success);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.lxb-msg .tr { color: var(--text-secondary); }
.lxb-msg .pts { color: var(--honey); font-weight: 700; }
.lxb-msg.bad b { color: var(--danger); }
.lxb-msg.level b { color: var(--honey); }

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

/* ---------- Touch controls (shown only on touch devices) ---------- */
.lxb-touch {
    display: none;
    width: 100%;
    max-width: 420px;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

body.touch .lxb-touch { display: grid; }

.lxb-tbtn {
    height: 54px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: rgba(3, 7, 18, 0.6);
    color: var(--text-primary);
    font-size: 1.35rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.lxb-tbtn:active { background: rgba(64, 196, 255, 0.28); }

.lxb-tbtn-drop {
    grid-column: span 4;
    font-size: 1rem;
    letter-spacing: 3px;
    color: #00121a;
    border: none;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.lxb-tbtn-drop:active { filter: brightness(1.15); }
.lxb-tbtn-pause { font-size: 0.9rem; }

/* ---------- Overlays (GAME PANEL STANDARD v2, Lexiblock copy) ---------- */
.lxb-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 12, 0.78);
    z-index: 4;
    padding: 16px;
    overflow-y: auto;
}

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

.lxb-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: min(94%, 420px);
    padding: 24px 26px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(64, 196, 255, 0.075), 0 0 40px rgba(64, 196, 255, 0.12);
}

.lxb-card-wide { width: min(94%, 560px); }

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

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

.lxb-card-title.lxb-title-win { color: var(--success); }
.lxb-card-title.lxb-title-fail { color: var(--danger); }

.lxb-tag {
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-muted);
}

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

.lxb-final b { color: var(--primary); }

.lxb-info {
    align-self: stretch;
    list-style: none;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-muted);
    max-height: 210px;
    overflow-y: auto;
}

.lxb-info li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 2px;
    border-bottom: 1px solid var(--border-color);
}

.lxb-info li:last-child { border-bottom: none; }

.lxb-info b {
    color: var(--success);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.lxb-info .miss b { color: var(--danger); }

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

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

/* start screen mode picker */
.lxb-pick-group {
    align-self: stretch;
    display: flex;
    gap: 8px;
}

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

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

.lxb-pick-btn.active {
    background: rgba(64, 196, 255, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

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

.lxb-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(64, 196, 255, 0.25);
}

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

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

.lxb-btn {
    padding: 12px 28px;
    border: none;
    border-radius: var(--card-radius);
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: #00121a;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: filter 0.15s ease;
}

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

.lxb-btn-secondary {
    padding: 12px 20px;
    border-radius: var(--card-radius);
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

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

.lxb-help {
    font-size: 0.72rem;
    letter-spacing: .5px;
    color: var(--text-muted);
}

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

.lxb-kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
}

.lxb-kbd:hover { border-color: var(--primary); color: var(--primary); }

.lxb-final-score {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--honey);
}

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

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

.lxb-keygroup h3 {
    margin-bottom: 8px;
    font-size: 0.72rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--secondary);
}

.lxb-keyblocks {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.lxb-capgrid {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    gap: 6px;
}

.lxb-capsame {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-muted);
}

.lxb-cap {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 52px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 3px;
    border-radius: var(--card-radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0.35));
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}

.lxb-cap-fn {
    margin-top: 4px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .5px;
    color: var(--primary);
}

.lxb-cap-off { opacity: .35; border-style: dashed; box-shadow: none; }
.lxb-cap-gap { visibility: hidden; }

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

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

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

.lxb-keypair .lxb-cap { min-width: 38px; height: 36px; font-size: 12px; }
.lxb-keypair .lxb-cap.lxb-cap-wide { min-width: 64px; }
.lxb-keypair .lxb-mini { border-bottom-width: 1px; box-shadow: none; }
.lxb-mini-good { background: rgba(76, 175, 80, 0.85); border-color: var(--success); }
.lxb-mini-bad { background: rgba(244, 67, 54, 0.85); border-color: var(--danger); }
.lxb-keysep { font-size: 12px; color: var(--text-muted); }
.lxb-keydesc { font-size: 0.85rem; color: var(--text-muted); }

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

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

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

.lxb-board-container {
    background: var(--surface-light);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-strong);
    border-left: 4px solid var(--primary);
    border-radius: 12px;
    padding: var(--standard-spacing);
}

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

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

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

.lxb-board-list li.lxb-board-top1 {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.45);
}

.lxb-board-list li.lxb-board-me { border: 1px solid var(--success); }

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

.lxb-board-score { font-weight: 700; color: var(--honey); }

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

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

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

/* ---------- Footer (site standard: honey copyright) ---------- */
.lxb-footer {
    display: flex;
    justify-content: center;
    padding-bottom: var(--standard-spacing);
}

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

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
    .lxb-page { padding: 12px; gap: 12px; }
    .title-img { max-width: 180px; }
    .lxb-subtitle { font-size: 0.85rem; }
    .lxb-game { padding: 10px 8px; gap: 8px; }
    .lxb-card { padding: 18px; gap: 9px; }
    .lxb-card-wide { padding: 16px 12px; }
    .lxb-final-score { font-size: 2rem; }
    .lxb-capgrid { grid-template-columns: repeat(3, 44px); }
    .lxb-capgrid .lxb-cap { min-width: 44px; height: 44px; font-size: 13px; }
    .lxb-keypair { min-width: 120px; }
    .lxb-hud { gap: 6px; }
    .lxb-hud-level { font-size: 0.72rem; letter-spacing: 0.5px; }
    .lxb-hud-score { font-size: 1.05rem; }
    .lxb-tools { gap: 4px; }
    .lxb-tool { width: 30px; height: 30px; font-size: 0.9rem; }
    .lxb-next-label { display: none; }
}

@media (max-width: 480px) {
    .title-img { max-width: 135px; }
}
