@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;800&family=Rajdhani:wght@400;600;700&display=swap');

:root {
    --bg-0: #040b12;
    --bg-1: #08111b;
    --bg-2: rgba(6, 19, 28, 0.78);
    --panel-border: rgba(89, 246, 255, 0.26);
    --line: rgba(89, 246, 255, 0.12);
    --text: #e7fbff;
    --muted: #8bb4be;
    --cyan: #59f6ff;
    --acid: #b3ff66;
    --amber: #ffb347;
    --crimson: #ff5f6d;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(89, 246, 255, 0.14), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 179, 71, 0.12), transparent 26%),
        linear-gradient(145deg, #02060c 0%, #07111a 48%, #061723 100%);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(89, 246, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(89, 246, 255, 0.04) 1px, transparent 1px);
    background-size: 42px 42px;
    pointer-events: none;
    opacity: 0.35;
}

.shell {
    position: relative;
    padding: 32px;
}

.hero,
.panel,
.board-panel {
    background: var(--bg-2);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 28px;
    border-radius: 24px;
    margin-bottom: 24px;
}

.eyebrow,
.section-label,
.hint,
label {
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.eyebrow,
.section-label {
    margin: 0 0 10px;
    color: var(--cyan);
    font-size: 0.82rem;
}

h1,
h2,
.turn-pill,
.mode-button,
.accent,
.ghost {
    font-family: 'Orbitron', sans-serif;
}

h1 {
    margin: 0;
    font-size: clamp(2.4rem, 4vw, 4.4rem);
    letter-spacing: 0.05em;
}

h2 {
    margin: 0;
    font-size: 1.2rem;
}

.subtitle {
    max-width: 50ch;
    margin: 12px 0 0;
    font-size: 1.1rem;
    color: var(--muted);
}

.hero-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    align-content: start;
    gap: 14px;
    min-width: 320px;
}

label {
    display: grid;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--muted);
}

input,
select,
button {
    border: 1px solid rgba(89, 246, 255, 0.24);
    border-radius: 14px;
    outline: none;
}

input,
select {
    padding: 12px 14px;
    color: var(--text);
    background: rgba(3, 10, 16, 0.86);
    font: inherit;
}

button {
    padding: 12px 16px;
    color: var(--text);
    background: rgba(7, 23, 33, 0.95);
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

button:hover {
    transform: translateY(-1px);
    border-color: rgba(89, 246, 255, 0.65);
    box-shadow: 0 0 0 1px rgba(89, 246, 255, 0.1), 0 10px 24px rgba(0, 0, 0, 0.28);
}

.ghost {
    grid-column: span 2;
}

.accent,
.mode-button.active {
    background: linear-gradient(135deg, rgba(89, 246, 255, 0.2), rgba(179, 255, 102, 0.12));
    border-color: rgba(179, 255, 102, 0.6);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 420px);
    gap: 24px;
}

.board-panel {
    padding: 22px;
    border-radius: 28px;
    overflow-x: auto;
}

.board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.turn-pill {
    padding: 12px 16px;
    border-radius: 999px;
    color: var(--cyan);
    border: 1px solid rgba(89, 246, 255, 0.3);
    background: rgba(3, 15, 24, 0.78);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.board {
    display: grid;
    grid-template-columns: repeat(10, minmax(64px, 1fr));
    gap: 8px;
}

.tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: 18px;
    padding: 8px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    font-size: 0.9rem;
    background: linear-gradient(165deg, rgba(8, 18, 28, 0.96), rgba(3, 10, 16, 0.96));
    border: 1px solid rgba(89, 246, 255, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.tile::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 12px;
    border: 1px solid rgba(89, 246, 255, 0.06);
    pointer-events: none;
}

.tile.stable {
    border-color: rgba(89, 246, 255, 0.14);
}

.tile.corrupted {
    border-color: rgba(255, 95, 109, 0.48);
    box-shadow: inset 0 0 30px rgba(255, 95, 109, 0.08);
}

.tile.shielded {
    border-color: rgba(179, 255, 102, 0.52);
    box-shadow: inset 0 0 30px rgba(179, 255, 102, 0.08);
}

.tile.reachable {
    box-shadow: 0 0 0 1px rgba(89, 246, 255, 0.18), inset 0 0 30px rgba(89, 246, 255, 0.08);
}

.tile.targetable {
    box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.22), inset 0 0 30px rgba(255, 179, 71, 0.08);
}

.tile.you {
    border-color: rgba(89, 246, 255, 0.7);
}

.tile.enemy {
    border-color: rgba(255, 95, 109, 0.64);
}

.tile-coordinate,
.tile-meta {
    position: relative;
    z-index: 1;
}

.tile-meta {
    text-align: right;
    font-size: 0.72rem;
    color: var(--muted);
}

.sidebar {
    display: grid;
    gap: 18px;
}

.panel {
    padding: 20px;
    border-radius: 24px;
}

.actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

#end-turn-button {
    grid-column: span 2;
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.players,
.message-log {
    display: grid;
    gap: 10px;
}

.player-card,
.message {
    padding: 14px;
    border-radius: 18px;
    background: rgba(2, 10, 16, 0.8);
    border: 1px solid rgba(89, 246, 255, 0.12);
}

.player-card.active-turn {
    border-color: rgba(179, 255, 102, 0.42);
}

.player-card header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.player-card h3,
.player-card p,
.message {
    margin: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    color: var(--muted);
}

.message-log {
    max-height: 260px;
    overflow: auto;
}

.message {
    color: var(--text);
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .board {
        gap: 6px;
    }
}

@media (max-width: 720px) {
    .shell {
        padding: 18px;
    }

    .hero {
        flex-direction: column;
    }

    .hero-panel {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .ghost,
    #end-turn-button {
        grid-column: auto;
    }

    .board-panel {
        padding: 16px;
    }
}

/* ─── Your-turn pill glow ─── */
@keyframes turn-glow {
    0%, 100% { box-shadow: 0 0 0 1px rgba(179, 255, 102, 0.35), 0 0 14px rgba(179, 255, 102, 0.14); }
    50%       { box-shadow: 0 0 0 1px rgba(179, 255, 102, 0.75), 0 0 28px rgba(179, 255, 102, 0.28); }
}

.turn-pill.your-turn {
    color: var(--acid);
    border-color: rgba(179, 255, 102, 0.55);
    animation: turn-glow 2s ease-in-out infinite;
}

/* ─── Your tile pulse ─── */
@keyframes you-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(89, 246, 255, 0.5),  inset 0 0 20px rgba(89, 246, 255, 0.10); }
    50%       { box-shadow: 0 0 0 2px rgba(89, 246, 255, 0.95), inset 0 0 38px rgba(89, 246, 255, 0.30); }
}

.tile.you {
    border-color: rgba(89, 246, 255, 0.85);
    animation: you-pulse 2.5s ease-in-out infinite;
}

/* ─── Tile occupant labels ─── */
.tile-who {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    padding: 3px 8px;
    border-radius: 7px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
}

.you-label {
    background: rgba(89, 246, 255, 0.20);
    color: var(--cyan);
    border: 1px solid rgba(89, 246, 255, 0.55);
}

.enemy-label {
    background: rgba(255, 95, 109, 0.20);
    color: var(--crimson);
    border: 1px solid rgba(255, 95, 109, 0.55);
}

/* ─── Stronger reachable / targetable ─── */
.tile.reachable {
    border-color: rgba(89, 246, 255, 0.5);
    box-shadow: 0 0 0 1px rgba(89, 246, 255, 0.22), inset 0 0 32px rgba(89, 246, 255, 0.14);
}

.tile.targetable {
    border-color: rgba(255, 179, 71, 0.55);
    box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.26), inset 0 0 32px rgba(255, 179, 71, 0.14);
}

/* ─── Hint variants ─── */
.hint.warning {
    color: var(--amber);
}

/* ─── Protocol badge ─── */
.protocol-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.60rem;
    background: rgba(89, 246, 255, 0.08);
    border: 1px solid rgba(89, 246, 255, 0.22);
    color: var(--cyan);
    white-space: nowrap;
    align-self: start;
}

.protocol-desc {
    margin: 0 0 10px;
    font-size: 0.74rem;
    color: var(--muted);
}

/* ─── Stat rows ─── */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 0.82rem;
}

.stat-label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.70rem;
    flex-shrink: 0;
}

.stat-value.hp {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.05rem;
    color: var(--cyan);
}

.stat-max {
    color: var(--muted);
    font-size: 0.75rem;
}

.stat-row.muted {
    color: var(--muted);
    font-size: 0.71rem;
    margin-top: 6px;
    margin-bottom: 0;
}

.danger-text { color: var(--crimson); }
.warn-text   { color: var(--amber); }

/* ─── AP pips ─── */
.ap-pips {
    display: flex;
    gap: 5px;
    align-items: center;
}

.ap-pip {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid rgba(89, 246, 255, 0.35);
    background: transparent;
    transition: background 200ms ease, box-shadow 200ms ease;
}

.ap-pip.full {
    background: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 0 6px rgba(89, 246, 255, 0.55);
}

/* ─── Buffer bar ─── */
.buffer-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 2px;
    margin: 2px 0 8px;
    overflow: hidden;
}

.buffer-fill {
    height: 100%;
    background: var(--cyan);
    border-radius: 2px;
    transition: width 0.4s ease;
    min-width: 1px;
}

.buffer-fill.warn   { background: var(--amber); }
.buffer-fill.danger { background: var(--crimson); }

/* ─── Tile legend ─── */
.tile-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.73rem;
    color: var(--muted);
}

.legend-dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 4px;
    border: 1.5px solid;
    flex-shrink: 0;
}

.legend-dot.stable     { border-color: rgba(89, 246, 255, 0.25); background: rgba(89, 246, 255, 0.04); }
.legend-dot.corrupted  { border-color: rgba(255, 95, 109, 0.60); background: rgba(255, 95, 109, 0.10); }
.legend-dot.shielded   { border-color: rgba(179, 255, 102, 0.60); background: rgba(179, 255, 102, 0.10); }
.legend-dot.reachable  { border-color: rgba(89, 246, 255, 0.50); background: rgba(89, 246, 255, 0.08); }
.legend-dot.targetable { border-color: rgba(255, 179, 71, 0.50);  background: rgba(255, 179, 71, 0.08); }
.legend-dot.you-dot    { border-color: rgba(89, 246, 255, 0.85); background: rgba(89, 246, 255, 0.20); }
.legend-dot.enemy-dot  { border-color: rgba(255, 95, 109, 0.85); background: rgba(255, 95, 109, 0.20); }

/* ─── Tips / How to Play panel ─── */
.tips-panel details > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.tips-panel details > summary::-webkit-details-marker {
    display: none;
}

.tips-panel details > summary::after {
    content: '▸';
    color: var(--cyan);
    font-size: 0.9rem;
    transition: transform 200ms ease;
}

.tips-panel details[open] > summary::after {
    transform: rotate(90deg);
}

.tips-panel details > summary .section-label {
    margin: 0;
}

.tips-body {
    margin-top: 14px;
    display: grid;
    gap: 10px;
}

.tip-item {
    padding: 9px 12px;
    border-left: 2px solid rgba(89, 246, 255, 0.20);
    font-size: 0.81rem;
    line-height: 1.55;
}

.tip-item strong {
    display: block;
    color: var(--cyan);
    margin-bottom: 3px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.tip-item p {
    margin: 0;
    color: var(--muted);
}

.tip-corrupted { color: var(--crimson); font-weight: 600; }
.tip-shielded  { color: var(--acid);    font-weight: 600; }
