/* ── Word Rogues theme ──────────────────────────────────────────────── */
:root {
    --tile: 48px;              /* board tile size - must match TilePx in Game.razor and TILE in board.js */
    --mini-tile: 26px;
    --bg: #1a1226;
    --panel: #291d3a;
    --panel-light: #372a4d;
    --accent: #f5a623;         /* lightning gold */
    --accent2: #7b5ce0;        /* rogue purple */
    --text: #efe8fb;
    --muted: #a294bd;
    --green: #2e9e4f;
    --blue: #2d6fd8;
    --red: #d83a3a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, sans-serif;
    overscroll-behavior: none;
}

h1, h2, h3 { margin: 0.4em 0; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.9em; }

/* ── Index / lobby pages ────────────────────────────────────────────── */
.index-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 24px 16px;
}

.game-title {
    text-align: center;
    font-size: 2.2rem;
    letter-spacing: 2px;
    color: var(--accent);
    text-shadow: 0 2px 8px rgba(245, 166, 35, 0.4);
}
.game-title.small { font-size: 1.1rem; text-shadow: none; white-space: nowrap; }
.bolt { color: var(--accent); }
.tagline { text-align: center; color: var(--muted); margin-top: -8px; }

.index-card {
    background: var(--panel);
    border: 1px solid var(--panel-light);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.text-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--panel-light);
    background: #1f1630;
    color: var(--text);
    font-size: 1rem;
}
.text-input:focus { outline: 2px solid var(--accent2); }

.index-tabs { display: flex; gap: 8px; margin: 8px 0; }
.tab-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--panel-light);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
}
.tab-btn.active { background: var(--accent2); color: white; border-color: var(--accent2); }

.primary-btn {
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(180deg, var(--accent), #cf8a12);
    color: #241a05;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}
.primary-btn:disabled { filter: grayscale(1); opacity: 0.5; cursor: default; }
.primary-btn.small { padding: 8px 14px; font-size: 0.9rem; }

.secondary-btn {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--accent2);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.error-text { color: #ff8484; font-size: 0.9rem; }

.ability-checks { display: flex; flex-direction: column; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.table-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-light);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border: 1px solid transparent;
}
.table-row.selected { border-color: var(--accent); }
.table-row-main { display: flex; flex-direction: column; }
.phase-chip { font-size: 0.75rem; padding: 3px 8px; border-radius: 10px; background: var(--green); }
.phase-chip.playing { background: var(--blue); }
.join-panel { display: flex; flex-direction: column; gap: 8px; padding: 8px 4px; }

.player-list { margin: 4px 0; padding-left: 20px; }

/* ── Game page layout ───────────────────────────────────────────────── */
.game-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--panel-light);
    z-index: 20;
}
.header-left { flex: 0 0 auto; }
.header-right { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }

.timer {
    font-variant-numeric: tabular-nums;
    font-weight: bold;
    font-size: 1.15rem;
    color: var(--accent);
    min-width: 52px;
}
.timer.urgent { color: #ff5c5c; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.icon-btn {
    background: transparent;
    border: 1px solid var(--panel-light);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    padding: 5px 9px;
    cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent2); }

/* Metallic banner (top-center) for power-ability announcements */
.banner-slot { flex: 1; display: flex; justify-content: center; min-height: 38px; }
.banner-display {
    padding: 6px 22px;
    border-radius: 8px;
    font-weight: bold;
    color: #fff8e0;
    background: linear-gradient(180deg, #3a2f52, #241a3a);
    border: 3px solid transparent;
    border-image: linear-gradient(135deg, #e8e8f0, #8a8a9a, #f4f4ff, #6f6f80, #dcdce8) 1;
    box-shadow: 0 0 14px rgba(245, 166, 35, 0.5), inset 0 0 8px rgba(255,255,255,0.12);
    animation: bannerIn 0.3s ease-out;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
@keyframes bannerIn { from { transform: translateY(-24px); opacity: 0; } }

/* Spectator tabs */
.spectate-tabs {
    display: flex;
    gap: 6px;
    padding: 6px 12px;
    background: var(--panel);
    overflow-x: auto;
}

/* ── Board ──────────────────────────────────────────────────────────── */
.board-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at center, #2a1f40 0%, var(--bg) 75%);
    touch-action: none;
    user-select: none;
}

.board-canvas {
    position: absolute;
    transform-origin: 0 0;
}

.square {
    position: absolute;
    width: var(--tile);
    height: var(--tile);
    border: 1px solid rgba(123, 92, 224, 0.25);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(41, 29, 58, 0.55);
}
.square:hover { border-color: var(--accent2); }

.square.filled {
    background: url("../img/tile.svg") center / cover no-repeat;
    border: none;
    color: #3b2a10;
    font-weight: bold;
    font-size: calc(var(--tile) * 0.55);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.square.selected {
    outline: 3px solid var(--accent);
    outline-offset: -2px;
    box-shadow: 0 0 12px rgba(245, 166, 35, 0.7);
    z-index: 2;
}

.square.valid { outline: 3px solid var(--green); outline-offset: -2px; }

.zoom-controls {
    position: absolute;
    right: 12px;
    top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}
.zoom-controls .icon-btn { background: var(--panel); font-size: 1.2rem; }

/* ── Bottom bar: orientation banner, rack, controls ─────────────────── */
.bottom-bar {
    background: var(--panel);
    border-top: 1px solid var(--panel-light);
    padding: 4px 10px 10px;
    z-index: 20;
}

.orient-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 30px;
}
.orient-banner {
    padding: 3px 16px;
    border-radius: 6px;
    color: white;
    font-weight: bold;
    letter-spacing: 2px;
    font-size: 0.85rem;
}
.orient-banner.horizontal { background: var(--green); }
.orient-banner.vertical { background: var(--blue); }

.orient-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.word-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    font-size: 1.05rem;
    letter-spacing: 1px;
    min-width: 6ch;   /* keeps space reserved when blank so layout doesn't jump */
}
.word-preview.preview-valid   { color: #7de87d; }
.word-preview.preview-scored  { color: var(--muted); }
.word-preview.preview-invalid { color: #e87d7d; }
.preview-tag { font-size: 0.82rem; font-weight: normal; letter-spacing: 0; }

.remove-btn {
    padding: 3px 12px;
    border-radius: 6px;
    border: 1px solid var(--red);
    background: transparent;
    color: #ff9a9a;
    font-size: 0.85rem;
    cursor: pointer;
}
.remove-btn:hover { background: var(--red); color: white; }

.red-x {
    background: var(--red);
    color: white;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 6px;
    animation: shake 0.3s;
}
@keyframes shake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.rack-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.power-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: radial-gradient(circle at 35% 30%, #4a3a6e, #241a3a);
    cursor: pointer;
    flex: 0 0 auto;
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.45);
}
.power-btn-bolt { font-size: 1.5rem; }

.rack {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    min-height: 48px;
    align-items: center;
}
.rack-empty { text-align: center; }

.rack-tile {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 6px;
    background: url("../img/tile.svg") center / cover no-repeat;
    color: #3b2a10;
    font-weight: bold;
    font-size: 1.4rem;
    cursor: pointer;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.rack-tile:hover { transform: translateY(-3px); }

.rack-side { display: flex; flex-direction: column; gap: 6px; align-items: center; flex: 0 0 auto; }
.pp-display { color: var(--accent); font-weight: bold; }
.live-score-display { color: #7de87d; font-weight: bold; font-size: 0.9rem; }

/* ── Freeze overlay ─────────────────────────────────────────────────── */
.freeze-overlay {
    position: fixed;
    inset: 0;
    background: rgba(120, 180, 255, 0.22);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}
.freeze-box {
    background: rgba(15, 40, 80, 0.9);
    border: 3px solid #9fd0ff;
    border-radius: 16px;
    padding: 26px 44px;
    font-size: 1.6rem;
    font-weight: bold;
    color: #d9edff;
    text-align: center;
    box-shadow: 0 0 30px rgba(159, 208, 255, 0.6);
}
.freeze-count { font-size: 2.4rem; margin-top: 8px; }

/* ── Side panels (chat / log) ───────────────────────────────────────── */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(340px, 90vw);
    height: 100dvh;
    background: var(--panel);
    border-left: 1px solid var(--panel-light);
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: -6px 0 18px rgba(0, 0, 0, 0.5);
}
.side-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--panel-light);
    font-weight: bold;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-name { color: var(--accent); font-weight: bold; }
.chat-input-row { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--panel-light); }
.log-entry { font-size: 0.9rem; }

/* ── Overlays ───────────────────────────────────────────────────────── */
.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 4, 16, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
    padding: 16px;
}
.overlay-panel {
    background: var(--panel);
    border: 1px solid var(--accent2);
    border-radius: 14px;
    max-width: 640px;
    width: 100%;
    max-height: 86dvh;
    overflow-y: auto;
    padding: 14px 18px;
}
.help-body { line-height: 1.5; font-size: 0.95rem; }

/* Power menu */
.power-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 10px 0;
}
.power-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border-radius: 10px;
    border: 1px solid var(--panel-light);
    background: var(--panel-light);
    cursor: pointer;
}
.power-card .power-icon { font-size: 1.8rem; }
.power-card .power-name { font-weight: bold; }
.power-card.afford .power-name {
    background: linear-gradient(90deg, #ffd76e, #ff8de3, #7be0ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.power-card.afford .power-cost { color: var(--accent); }
.power-card.broke { filter: grayscale(1); opacity: 0.55; cursor: default; }
.power-card.broke .power-name, .power-card.broke .power-cost { color: #9a9a9a; }

.target-list { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }

.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding: 10px 0;
}
.alpha-tile {
    aspect-ratio: 1;
    border: none;
    border-radius: 6px;
    background: url("../img/tile.svg") center / cover no-repeat;
    color: #3b2a10;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
}
.alpha-tile.chosen { outline: 3px solid var(--accent); }

.confirm-row { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px 0; }

/* Mini board (break board / spectate) */
.mini-board-wrap { overflow: auto; max-height: 50dvh; padding: 8px 0; }
.mini-board { display: grid; gap: 2px; width: max-content; }
.mini-tile {
    width: var(--mini-tile);
    height: var(--mini-tile);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-tile.filled {
    background: url("../img/tile.svg") center / cover no-repeat;
    color: #3b2a10;
    font-weight: bold;
    cursor: pointer;
}
.mini-tile.filled:hover { outline: 2px solid var(--red); }

/* Game over */
.gameover-panel h2 { text-align: center; color: var(--accent); }
.score-row {
    background: var(--panel-light);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 4px 10px;
    align-items: center;
}
.score-row.winner { border: 2px solid var(--accent); box-shadow: 0 0 12px rgba(245, 166, 35, 0.4); }
.rank { font-weight: bold; color: var(--accent); }
.score-name { font-weight: bold; }
.score-total { font-weight: bold; color: var(--accent); }
.score-words { grid-column: 1 / -1; }

/* Game-over board viewer (tab per player, hover a tile for its words + points) */
.final-tabs { display: flex; gap: 6px; margin: 12px 0 8px; overflow-x: auto; }
.final-board-wrap { overflow: auto; max-height: 40dvh; padding: 4px 0; display: flex; justify-content: center; }
.final-board-wrap .mini-tile.filled { cursor: help; }
.final-board-wrap .mini-tile.filled:hover { outline: 2px solid var(--accent); }
.final-board-note { font-size: 0.85rem; margin: 4px 0 8px; }
.mini-tile.filled.dead { filter: grayscale(1) brightness(0.55); }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #5c2626; padding: 8px 16px; z-index: 999; }
#blazor-error-ui .reload { color: white; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ── Ready screen (pre-game ready check + 3s countdown) ─────────────── */
.ready-panel { text-align: center; min-width: 300px; }
.ready-countdown {
    font-size: 4rem;
    font-weight: bold;
    color: var(--accent);
    animation: pulse 1s infinite;
}
@keyframes pulse { 50% { transform: scale(1.15); } }
.ready-list { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.ready-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--panel-light);
}
.ready-yes { color: var(--green); font-weight: bold; }
.ready-no { color: #9a9a9a; }

/* ── Inline PC ability bar (rows under the rack, 5 per row, hotkeys 1-9/0) ── */
.ability-bar { margin-top: 6px; }
.power-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.power-card.bar-card {
    position: relative;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    padding: 6px 8px 6px 24px;
    font-size: 0.85rem;
}
.power-card.bar-card .power-icon { font-size: 1.2rem; }
.power-card.bar-card .power-name { font-size: 0.85rem; white-space: nowrap; }
.power-card.bar-card .power-cost { font-size: 0.8rem; white-space: nowrap; }
.hotkey-badge {
    position: absolute;
    top: 4px;
    left: 6px;
    min-width: 16px;
    padding: 0 3px;
    border-radius: 4px;
    background: var(--panel);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: bold;
    text-align: center;
}
.power-bar-wrap .error-text { text-align: center; }

/* PC vs mobile: wide screens get the ability bar, narrow screens keep the ⚡ popup. */
.mobile-only { display: none; }
@media (max-width: 900px) {
    .mobile-only { display: block; }
    .pc-only { display: none; }
}

/* Mobile tweaks */
@media (max-width: 600px) {
    .game-title.small { display: none; }
    .rack-tile { width: 38px; height: 38px; font-size: 1.2rem; }
    .power-btn { width: 46px; height: 46px; }
}

/* ── Home page: Play / Guide top-level tabs ─────────────────────────── */
.home-page-tabs { display: flex; gap: 8px; margin-bottom: 12px; max-width: 500px; }
.guide-card { max-width: 700px; }
.guide-card h3 { color: var(--accent); margin: 20px 0 8px; }
.guide-card h3:first-child { margin-top: 0; }
.guide-card ul { margin: 0 0 8px; padding-left: 20px; line-height: 1.7; }
.guide-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px;
    font-size: 0.92rem;
}
.guide-table th {
    text-align: left;
    padding: 6px 10px;
    background: var(--panel-light);
    color: var(--accent);
    border-radius: 4px;
}
.guide-table td {
    padding: 5px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.guide-note { font-size: 0.88rem; margin: 4px 0 10px; }
.ability-guide-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ability-guide-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--panel-light);
    border-radius: 8px;
    padding: 10px 12px;
}
.ability-guide-row.ability-disabled { opacity: 0.4; }
.ability-guide-icon { font-size: 1.5rem; min-width: 32px; text-align: center; }
.ability-guide-body { display: flex; flex-direction: column; gap: 2px; }
.ability-guide-name { font-weight: bold; }
.ability-guide-cost { font-size: 0.85rem; color: var(--accent); }
.ability-guide-desc { font-size: 0.88rem; }
