:root {
    --pink: #ff3aa6;
    --cyan: #35d0ff;
    --yellow: #ffe9a8;
    --panel-bg: rgba(20, 8, 38, 0.82);
}

* {
    box-sizing: border-box;
}

html,
body,
#root {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #0a0418;
    color: #fff;
    font-family: 'Trebuchet MS', 'Segoe UI', Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#game-container {
    position: absolute;
    inset: 0;
}

/* ---------- Overlays ---------- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.overlay--solid {
    background: radial-gradient(
        ellipse at center,
        rgba(42, 17, 64, 0.55),
        rgba(10, 4, 24, 0.9)
    );
    backdrop-filter: blur(2px);
}

/* During play the overlay must let taps reach the game canvas. The controls
   sit at the bottom-left so they never cover the hearts HUD (top-left). */
.overlay--passthrough {
    pointer-events: none;
    align-items: flex-end;
    justify-content: flex-start;
}
.overlay--passthrough > * {
    pointer-events: auto;
}

/* ---------- Panel ---------- */
.panel {
    width: min(440px, 92vw);
    max-height: 92vh;
    overflow-y: auto;
    background: var(--panel-bg);
    border: 2px solid rgba(255, 58, 166, 0.5);
    border-radius: 22px;
    padding: 24px 22px 28px;
    box-shadow: 0 0 40px rgba(255, 58, 166, 0.35), inset 0 0 30px rgba(53, 208, 255, 0.12);
    text-align: center;
}

.title {
    margin: 0 0 4px;
    font-size: clamp(34px, 8vw, 52px);
    font-weight: 900;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 0 14px var(--pink), 0 0 28px var(--cyan);
}

.tagline {
    margin: 0 0 22px;
    color: #d9c7ff;
    font-size: clamp(13px, 3.6vw, 16px);
}

.field {
    margin-bottom: 18px;
    text-align: left;
}

.field__label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--cyan);
}

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

.btn-row--center {
    margin-top: 8px;
}

/* ---------- Chips (selectors) ---------- */
.chip {
    min-width: 42px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chip--wide {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 40%;
    justify-content: center;
}

.chip__sym {
    font-size: 20px;
    color: var(--cyan);
}

.chip:hover {
    border-color: var(--cyan);
}

.chip.active {
    border-color: var(--pink);
    background: rgba(255, 58, 166, 0.22);
    box-shadow: 0 0 16px rgba(255, 58, 166, 0.5);
}

.chip.active .chip__sym {
    color: #fff;
}

/* ---------- Buttons ---------- */
.play-btn {
    margin-top: 12px;
    padding: 14px 30px;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #1a0322;
    background: linear-gradient(135deg, var(--pink), var(--cyan));
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 0 24px rgba(53, 208, 255, 0.55);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 34px rgba(255, 58, 166, 0.7);
}

.play-btn:disabled {
    opacity: 0.5;
    cursor: wait;
    box-shadow: none;
}

.ghost-btn {
    padding: 14px 22px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.ghost-btn:hover {
    border-color: var(--cyan);
}

.back-btn {
    margin: 14px;
    padding: 8px 16px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: rgba(20, 8, 38, 0.65);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
}

.back-btn:hover {
    border-color: var(--pink);
}

/* ---------- Game over ---------- */
.panel--over {
    width: min(360px, 90vw);
}

.title--over {
    text-shadow: 0 0 14px #ff4d4d, 0 0 28px var(--pink);
}

.final-sub {
    margin: 6px 0 0;
    color: #d9c7ff;
    font-size: 15px;
    letter-spacing: 1px;
}

.final-score {
    margin: 10px 0 0;
    font-size: clamp(48px, 16vw, 84px);
    font-weight: 900;
    line-height: 1;
    color: var(--yellow);
    text-shadow: 0 0 20px rgba(255, 233, 168, 0.7);
}

.final-label {
    margin: 0 0 18px;
    color: #d9c7ff;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 13px;
}

/* ---------- Name input ---------- */
.text-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input::placeholder {
    color: rgba(217, 199, 255, 0.5);
    font-weight: 400;
}

.text-input:focus {
    border-color: var(--pink);
    box-shadow: 0 0 16px rgba(255, 58, 166, 0.5);
}

/* ---------- Leaderboard ---------- */
.field--lb {
    margin-top: 22px;
    margin-bottom: 4px;
    text-align: center;
}

.leaderboard {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lb-row {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    grid-template-areas: 'rank name score' 'rank meta score';
    align-items: center;
    column-gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}

.lb-row--me {
    border-color: var(--pink);
    background: rgba(255, 58, 166, 0.18);
    box-shadow: 0 0 14px rgba(255, 58, 166, 0.4);
}

.lb-rank {
    grid-area: rank;
    font-weight: 900;
    font-size: 15px;
    color: var(--cyan);
    text-align: center;
}

.lb-name {
    grid-area: name;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-meta {
    grid-area: meta;
    font-size: 11px;
    color: #b9a7e0;
    letter-spacing: 0.5px;
}

.lb-score {
    grid-area: score;
    font-weight: 900;
    font-size: 18px;
    color: var(--yellow);
    text-shadow: 0 0 10px rgba(255, 233, 168, 0.5);
}

.lb-empty {
    margin: 4px 0 0;
    color: #b9a7e0;
    font-size: 14px;
}

.lb-placement {
    margin: 0 0 14px;
    color: var(--yellow);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.5px;
}

/* Menu action row: Play + Leaderboard side by side. */
.menu-actions {
    margin-top: 12px;
    align-items: center;
}
.menu-actions .play-btn {
    margin-top: 0;
}

/* Board caption (which grade + theme this board is for). */
.lb-board {
    margin: 0 0 10px;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Difficulty badge per row (boards mix difficulties). */
.lb-meta {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.lb-diff--easy {
    color: #7dffb0;
}
.lb-diff--medium {
    color: #ffd24d;
}
.lb-diff--hard {
    color: #ff6ba8;
}
