/* ─────────────────────────────────────────────────────────────────────────────
   SPA root (#app) & game layout grid
──────────────────────────────────────────────────────────────────────────────*/
#app {
    min-height: 100vh;
}

#app.game-layout {
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr min(300px, 15vw);
    grid-template-rows: 60px 1fr max(200px, 20vh);
}

/* ── Game view — map, chat, toolbox grid placements ─────────────────────────*/
#map {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    overflow: hidden;
}

#map-canvas {
    width: 100%;
    height: 100%;
}

#chat {
    grid-column: 2;
    grid-row: 2 / 4;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#toolbox {
    grid-column: 1;
    grid-row: 3;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-default);
    display: flex;
    align-items: stretch;
    padding: 0.4rem 0.75rem;
    gap: 0.5rem;
}

/* ── Quiet overlay — frozen seeker screen ────────────────────────────*/
.quiet-overlay {
    grid-column: 1 / -1;
    grid-row: 2 / 4;
    z-index: 800;
    background: rgba(30, 30, 30, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.quiet-content {
    text-align: center;
    user-select: none;
}

.quiet-emoji {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.quiet-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.02em;
}

.quiet-sub {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

/* ── Mirror Mirror — flip the display horizontally ─────────────────────*/
#app.app-mirror {
    transform: scaleX(-1);
}

/* ── Granny's Card — cursive font for seeker clues & chat ──────────────*/
#app.app-granny .bubble,
#app.app-granny .clue-btn,
#app.app-granny .clue-hover-card {
    font-family: 'The Nautigal', cursive !important;
    font-weight: 700;
    font-size: 1.1em;
}

/* Scale up hover card text too since cursive runs small */
#app.app-granny .clue-hover-text {
    font-size: 1.3em;
}

#app.app-granny .clue-hover-cost {
    font-size: 1.1em;
}

#toolbox .scroll-wrap {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    overflow-x: auto;
    flex: 1;
    align-self: stretch;
}

/* ── Game Over overlay ────────────────────────────────────────────────*/
.gameover-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: gameover-fade-in 0.5s ease-out;
}

@keyframes gameover-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.gameover-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2.5rem 3rem;
    background: rgba(20, 20, 30, 0.95);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    max-width: 520px;
    width: 90%;
}

.gameover-announce {
    font-size: 1.8rem;
    color: #fff;
    line-height: 1.5;
    margin: 0;
    max-width: 600px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
}

.gameover-name {
    color: #ffd700;
    font-weight: 800;
}

.gameover-location {
    color: #4fc3f7;
    font-weight: 800;
}

.gameover-title {
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
}

.gameover-continue-btn {
    padding: 0.75rem 3rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gameover-continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.5);
}

/* ── End Game view ────────────────────────────────────────────────────*/
.endgame-view {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    gap: 1.25rem;
}

.endgame-header {
    text-align: center;
}

.endgame-title {
    font-size: clamp(1.8rem, 6vw, 3.5rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.endgame-title--found {
    color: #28a745;
    text-shadow: 0 0 30px rgba(40, 167, 69, 0.4);
}

.endgame-title--timeout {
    color: #dc3545;
    text-shadow: 0 0 30px rgba(220, 53, 69, 0.4);
}

/* ── Shared layout for timeout and found sections ────────────────────*/
.endgame-timeout,
.endgame-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    max-width: 680px;
}

/* ── 3-column stat grid ──────────────────────────────────────────────*/
.endgame-stats {
    display: grid;
    gap: 0.75rem;
    width: 100%;
}

.endgame-stats--3col {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 500px) {
    .endgame-stats--3col {
        grid-template-columns: repeat(2, 1fr);
    }
}

.endgame-stat-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 0.75rem 0.5rem;
    text-align: center;
    min-width: 0;
    overflow: hidden;
}

.endgame-stat-card--total {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
}

.endgame-stat-label {
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.endgame-stat-value {
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 700;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.endgame-stat-value--penalty {
    color: #ffc107;
}

.endgame-stat-value--bonus {
    color: #0dcaf0;
}

.endgame-stat-value--name {
    font-size: clamp(0.85rem, 2.5vw, 1.3rem);
}

/* ── Location line ───────────────────────────────────────────────────*/
.endgame-location-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
    text-align: center;
}

.endgame-location-line .bi {
    color: #dc3545;
    font-size: 1.1em;
    flex-shrink: 0;
}

/* ── Timeout map ─────────────────────────────────────────────────────*/
.endgame-map-container {
    width: 100%;
    max-width: 600px;
    height: 300px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.endgame-map-canvas {
    width: 100%;
    height: 100%;
}

.endgame-info {
    text-align: center;
    max-width: 500px;
}

.endgame-evade-msg {
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    color: #f8f9fa;
    margin: 0;
}

/* ── End cards section ───────────────────────────────────────────────*/
.endgame-cards-section {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1rem 1.25rem;
}

.endgame-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.65rem;
    color: #ffc107;
}

.endgame-cards-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.endgame-card-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

.endgame-card-count {
    font-weight: 700;
    color: #6c757d;
    min-width: 1.8rem;
    flex-shrink: 0;
}

.endgame-card-title {
    flex: 1;
    word-break: break-word;
    overflow-wrap: break-word;
}

.endgame-card-bonus {
    font-weight: 700;
    color: #ffc107;
    flex-shrink: 0;
}

.endgame-no-cards {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
}

/* ── Action buttons ──────────────────────────────────────────────────*/
.endgame-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.endgame-actions .btn {
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.15s, box-shadow 0.15s;
}

.endgame-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
