:root {
    --cw-bg: #0a1a0a;
    --cw-bg-primary: #1a3a1a;
    --cw-bg-card: rgba(30, 50, 30, 0.95);
    --cw-bg-card-end: rgba(20, 35, 20, 0.95);
    --cw-bg-overlay: rgba(10, 26, 10, 0.92);
    --cw-bg-panel: rgba(30, 50, 30, 0.95);
    --cw-bg-dim: rgba(10, 26, 10, 0.95);
    --cw-accent: #c9a84c;
    --cw-text: #faf3e0;
    --cw-btn-hover-text: #1a3a1a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--cw-bg);
    font-family: 'Lora', Georgia, serif;
    color: #faf3e0;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Rotate prompt — shown to phones held in portrait */
#rotate-prompt {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cw-bg);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    color: #faf3e0;
    font-family: 'Cinzel', serif;
    text-align: center;
    padding: 28px 24px;
    /* The big-screen note pushes past the viewport on short phones, so this
       one overlay is allowed to scroll even though html/body are locked. */
    overflow-y: auto;
}

#rotate-prompt h2 {
    color: #c9a84c;
    font-size: 1.4rem;
    letter-spacing: 1px;
}

#rotate-prompt p {
    color: rgba(250, 243, 224, 0.5);
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    line-height: 1.6;
}

.phone-icon-box {
    font-size: 3rem;
    opacity: 0.7;
}

/* Landscape on a phone is the fallback, not the recommendation. This block
   says so before the player commits to a hand on a 5 inch screen. */
.big-screen-note {
    max-width: 22rem;
    padding-top: 16px;
    border-top: 1px solid rgba(250, 243, 224, 0.15);
}

.big-screen-note strong {
    display: block;
    color: var(--cw-accent);
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

/* Outranks the dimmer #rotate-prompt p rule above. */
#rotate-prompt .big-screen-note p {
    color: rgba(250, 243, 224, 0.75);
    font-size: 0.9rem;
}

/* Phones in portrait: ask for landscape. The board needs the width — both
   players' hunt strips and the hand tray only fit side-on. Phones in landscape
   fall through to the canvas renderer's mobile layout and play normally.
   The 600px cap keeps tablets out: an iPad in portrait is 768 wide and keeps
   the desktop layout, exactly as before. */
/* The landscape-phone counterpart to the rotate prompt. A player who is already
   sideways gets the same bigger-screen recommendation once, as a small banner
   they can dismiss, instead of the full-screen block. Hidden by default at every
   size; the media query below is what lets it appear, and JS decides whether it
   should. Never grows tall enough to cover the canvas hand tray. */
#bigscreen-tip {
    display: none;
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 24px);
    padding: 7px 8px 7px 14px;
    border: 1px solid var(--cw-accent);
    border-radius: 999px;
    background: rgba(10, 15, 10, 0.92);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    /* Sits above the canvas, so keep it out of the way of taps that are not
       aimed at the dismiss button. */
    pointer-events: none;
}

#bigscreen-tip p {
    margin: 0;
    color: rgba(250, 243, 224, 0.92);
    font-family: 'Lora', serif;
    font-size: 0.78rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#bigscreen-tip button {
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(250, 243, 224, 0.12);
    color: var(--cw-text);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    /* The one part of the banner that accepts input. */
    pointer-events: auto;
}

#bigscreen-tip button:active { background: rgba(250, 243, 224, 0.25); }

/* Phones held sideways: short viewport, coarse pointer. Matches the height half
   of the CW.isMobile query in index.php, so the banner shows exactly when the
   canvas is using its mobile layout in landscape. */
@media (pointer: coarse) and (max-height: 440px) and (orientation: landscape) {
    #bigscreen-tip:not([hidden]) { display: flex; }
}

/* Phones in portrait: ask for landscape. The board needs the width — both
   players' hunt strips and the hand tray only fit side-on. Phones in landscape
   fall through to the canvas renderer's mobile layout and play normally.
   The 600px cap keeps tablets out: an iPad in portrait is 768 wide and keeps
   the desktop layout, exactly as before. */
@media (pointer: coarse) and (max-width: 600px) and (orientation: portrait) {
    #rotate-prompt { display: flex; }
    #game-container { display: none; }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cw-bg-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-card {
    text-align: center;
    padding: 40px 60px;
    background: var(--cw-bg-card);
    border: 2px solid var(--cw-accent);
    border-radius: 12px;
}

.loading-card h2 {
    font-family: 'Cinzel', serif;
    color: #c9a84c;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.loading-bar {
    width: 240px;
    height: 8px;
    background: rgba(250, 243, 224, 0.15);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 10px;
}

.loading-fill {
    height: 100%;
    background: #c9a84c;
    border-radius: 4px;
    transition: width 0.2s;
}

.loading-card p {
    color: rgba(250, 243, 224, 0.5);
    font-size: 0.85rem;
}

/* Player Select Overlay */
.player-select-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cw-bg-overlay);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 16px;
    z-index: 90;
}

/* auto margins centre the card when there is room and fall back to the top
   when there is not, so a tall card scrolls instead of losing its header. */
.player-select-overlay > * {
    margin: auto;
}

.select-card {
    text-align: center;
    padding: 50px 60px;
    background: linear-gradient(145deg, var(--cw-bg-card), var(--cw-bg-card-end));
    border: 2px solid var(--cw-accent);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.select-card h2 {
    font-family: 'Cinzel', serif;
    color: var(--cw-accent);
    font-size: 2rem;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.select-card > p {
    color: rgba(250, 243, 224, 0.6);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.select-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 20px;
}

.select-buttons button {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 14px 28px;
    background: rgba(201, 168, 76, 0.15);
    border: 2px solid #c9a84c;
    color: #c9a84c;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.select-buttons button:hover {
    background: var(--cw-accent);
    color: var(--cw-btn-hover-text);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.3);
}

.select-sub {
    color: rgba(250, 243, 224, 0.35);
    font-size: 0.85rem;
}

.select-buttons button:disabled,
.select-buttons button:disabled:hover {
    opacity: 0.45;
    cursor: default;
    transform: none;
    box-shadow: none;
    background: rgba(201, 168, 76, 0.15);
    color: #c9a84c;
}

/* Login / code-entry flow */
.cw-login-card {
    max-width: 440px;
    padding: 34px 32px;
}

.cw-login-card h2 {
    margin-bottom: 14px;
}

.cw-login-lead {
    color: rgba(250, 243, 224, 0.6);
    font-size: 1rem;
    line-height: 1.5;
}

.cw-login-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(250, 243, 224, 0.08);
    border: 1px solid rgba(201, 168, 76, 0.4);
    border-radius: 6px;
    color: #faf3e0;
    font-family: 'Lora', serif;
    font-size: 1rem;
}

/* The "we sent it" affirmation. Deliberately loud: the whole problem this
   solves is players not believing anything happened. */
.cw-sent-panel {
    background: rgba(90, 158, 90, 0.1);
    border: 1px solid rgba(90, 158, 90, 0.45);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 22px;
    text-align: center;
}

.cw-sent-panel.is-flash {
    animation: cw-sent-flash 0.9s ease-out;
}

@keyframes cw-sent-flash {
    0%   { background: rgba(90, 158, 90, 0.42); border-color: #5a9e5a; }
    100% { background: rgba(90, 158, 90, 0.1); border-color: rgba(90, 158, 90, 0.45); }
}

.cw-sent-title {
    font-family: 'Cinzel', serif;
    color: #7fc47f;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
    margin: 0 0 4px;
}

.cw-sent-title::before {
    content: '\2713';
    margin-right: 8px;
}

.cw-sent-email {
    color: #c9a84c;
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    word-break: break-all;
    margin: 0 0 10px;
}

.cw-sent-note {
    color: rgba(250, 243, 224, 0.62);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0;
}

.cw-sent-age {
    color: rgba(250, 243, 224, 0.4);
    font-size: 0.75rem;
    margin: 8px 0 0;
    font-variant-numeric: tabular-nums;
}

.cw-code-label {
    display: block;
    color: rgba(250, 243, 224, 0.7);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.cw-code-input {
    width: 190px;
    padding: 12px;
    background: rgba(250, 243, 224, 0.08);
    border: 1px solid rgba(201, 168, 76, 0.4);
    border-radius: 6px;
    color: #c9a84c;
    font-family: monospace;
    font-size: 1.7rem;
    text-align: center;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
}

.cw-code-input:focus {
    outline: none;
    border-color: #c9a84c;
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18);
}

.cw-resend-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.cw-resend-row span {
    color: rgba(250, 243, 224, 0.5);
    font-size: 0.85rem;
}

.cw-linkbtn {
    background: none;
    border: none;
    padding: 0;
    color: rgba(250, 243, 224, 0.5);
    font-family: 'Lora', serif;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
}

.cw-linkbtn:hover:not(:disabled) {
    color: #c9a84c;
}

.cw-linkbtn:disabled {
    cursor: default;
    text-decoration: none;
    color: rgba(250, 243, 224, 0.35);
    font-variant-numeric: tabular-nums;
}

.cw-linkbtn.is-strong {
    color: #c9a84c;
    font-weight: 700;
}

.cw-login-msg {
    font-size: 0.85rem;
    margin-top: 10px;
    min-height: 1.2em;
    line-height: 1.4;
}

.cw-login-msg.is-error { color: #e06565; }
.cw-login-msg.is-ok    { color: #7fc47f; }

.cw-login-fineprint {
    color: rgba(250, 243, 224, 0.35);
    font-size: 0.75rem;
    line-height: 1.5;
    margin-top: 14px;
}

.opponent-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 20px;
}

.opponent-list li {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: #c9a84c;
    padding: 6px 0;
    letter-spacing: 0.5px;
}

.begin-hunt-btn {
    font-size: 1.05rem !important;
    padding: 14px 36px !important;
    letter-spacing: 1px;
}

/* Tutorial Banner - top center, above the piles */
.tutorial-banner {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--cw-bg-panel);
    border: 1px solid rgba(201, 168, 76, 0.6);
    border-radius: 8px;
    padding: 12px 28px;
    max-width: 420px;
    text-align: center;
    font-size: 0.95rem;
    color: #faf3e0;
    z-index: 50;
    animation: tutorialFadeIn 0.3s ease;
    pointer-events: none;
}

@keyframes tutorialFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Action Log - compact bottom-left, below hand cards */
.action-log {
    position: absolute;
    bottom: 2px;
    left: 8px;
    width: 220px;
    max-height: 48px;
    overflow: hidden;
    z-index: 40;
    pointer-events: none;
    background: rgba(10, 26, 10, 0.4);
    border-radius: 4px;
    padding: 4px 4px;
}

.log-entry {
    font-size: 0.7rem;
    color: rgba(250, 243, 224, 0.5);
    padding: 1px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: logFade 0.3s ease;
}

.log-entry:last-child {
    color: rgba(250, 243, 224, 0.85);
}

@keyframes logFade {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Game Over Overlay */
.game-over-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cw-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
}

.gameover-card {
    text-align: center;
    padding: 40px 50px;
    background: linear-gradient(145deg, var(--cw-bg-card), var(--cw-bg-card-end));
    border: 2px solid var(--cw-accent);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    min-width: 320px;
}

.gameover-card h2 {
    font-family: 'Cinzel', serif;
    color: var(--cw-accent);
    font-size: 2rem;
    margin-bottom: 8px;
}

.gameover-sub {
    color: rgba(250, 243, 224, 0.6);
    margin-bottom: 24px;
}

.gameover-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}

.gameover-stats div {
    background: rgba(250, 243, 224, 0.06);
    padding: 10px;
    border-radius: 6px;
}

.gameover-stats span {
    display: block;
    font-size: 0.75rem;
    color: rgba(250, 243, 224, 0.45);
    margin-bottom: 4px;
}

.gameover-stats strong {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: #c9a84c;
}

.replay-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 36px;
    background: var(--cw-accent);
    border: none;
    color: var(--cw-btn-hover-text);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.replay-btn:hover {
    background: #dfc575;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4);
}

/* Scoreboard Overlay */
.scoreboard-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cw-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 85;
}

.scoreboard-card {
    text-align: center;
    padding: 40px 50px;
    background: linear-gradient(145deg, var(--cw-bg-card), var(--cw-bg-card-end));
    border: 2px solid var(--cw-accent);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    min-width: 340px;
    max-width: 420px;
}

.scoreboard-card h2 {
    font-family: 'Cinzel', serif;
    color: #c9a84c;
    font-size: 1.8rem;
    margin-bottom: 20px;
    letter-spacing: 0.05em;
}

.scoreboard-result {
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 8px;
    background: rgba(250, 243, 224, 0.04);
}

.scoreboard-result h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.scoreboard-result.result-win h3 { color: #4CAF50; }
.scoreboard-result.result-loss h3 { color: #b33030; }

.scoreboard-result p {
    color: rgba(250, 243, 224, 0.5);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.scoreboard-game-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.scoreboard-game-stats span {
    color: rgba(250, 243, 224, 0.4);
    font-size: 0.8rem;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    font-family: 'Lora', serif;
    font-size: 0.9rem;
}

.leaderboard-table thead th {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: rgba(250, 243, 224, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px 8px;
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
    text-align: center;
}

.leaderboard-table thead th:nth-child(2) {
    text-align: left;
}

.leaderboard-table tbody td {
    padding: 8px 8px;
    color: rgba(250, 243, 224, 0.6);
    text-align: center;
    border-bottom: 1px solid rgba(250, 243, 224, 0.05);
}

.leaderboard-table tbody td:nth-child(1) {
    font-family: 'Cinzel', serif;
    color: rgba(201, 168, 76, 0.5);
    font-size: 0.85rem;
    width: 28px;
}

.leaderboard-table tbody td:nth-child(2) {
    text-align: left;
    font-weight: 700;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table tbody tr.leaderboard-you td {
    color: #c9a84c;
}

.leaderboard-table tbody tr.leaderboard-you td:nth-child(2) {
    font-family: 'Cinzel', serif;
}

.scoreboard-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scoreboard-play-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 14px 36px;
    background: var(--cw-accent);
    border: none;
    color: var(--cw-btn-hover-text);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.scoreboard-play-btn:hover {
    background: #dfc575;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4);
}

.scoreboard-leave-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 24px;
    background: transparent;
    border: 1px solid rgba(250, 243, 224, 0.2);
    color: rgba(250, 243, 224, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.scoreboard-leave-btn:hover {
    border-color: rgba(250, 243, 224, 0.4);
    color: rgba(250, 243, 224, 0.8);
}

/* Discard / Cancel Buttons */
.discard-btn, .cancel-btn {
    position: absolute;
    z-index: 60;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.discard-btn {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(139, 26, 26, 0.7);
    border: 1px solid #b33030;
    color: #faf3e0;
}

.discard-btn:hover {
    background: #b33030;
}

.cancel-btn {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(250, 243, 224, 0.1);
    border: 1px solid rgba(250, 243, 224, 0.3);
    color: #faf3e0;
}

.cancel-btn:hover {
    background: rgba(250, 243, 224, 0.2);
}

/* ===== Action Panel ===== */
.action-panel {
    position: absolute;
    z-index: 58;
    text-align: center;
    pointer-events: none;
}

.action-prompt {
    font-family: 'Lora', serif;
    font-size: 0.88rem;
    color: rgba(250, 243, 224, 0.85);
    margin-bottom: 10px;
    padding: 8px 14px;
    background: var(--cw-bg-overlay);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 8px;
    line-height: 1.4;
}

.action-prompt.alert {
    color: var(--cw-accent);
    border-color: rgba(201, 168, 76, 0.6);
    background: var(--cw-bg-panel);
}

.action-prompt.ai-narration {
    color: rgba(250, 243, 224, 0.5);
    font-style: italic;
    border-color: rgba(250, 243, 224, 0.1);
}

.action-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    pointer-events: auto;
}

.action-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.action-btn.primary {
    background: rgba(201, 168, 76, 0.18);
    border: 2px solid #c9a84c;
    color: #c9a84c;
}

.action-btn.primary:hover {
    background: var(--cw-accent);
    color: var(--cw-btn-hover-text);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(201, 168, 76, 0.3);
}

.action-btn.danger {
    background: rgba(139, 26, 26, 0.18);
    border: 1px solid rgba(179, 48, 48, 0.4);
    color: rgba(250, 243, 224, 0.55);
}

.action-btn.danger:hover {
    background: rgba(139, 26, 26, 0.5);
    color: #faf3e0;
}

.action-btn.secondary {
    background: rgba(250, 243, 224, 0.06);
    border: 1px solid rgba(250, 243, 224, 0.2);
    color: rgba(250, 243, 224, 0.6);
}

.action-btn.secondary:hover {
    background: rgba(250, 243, 224, 0.12);
    color: #faf3e0;
    transform: translateY(-1px);
}

/* Scrollbar */
/* Phones in landscape: the canvas mobile layout puts the player's own strip
   (name, trophy medallions, what they still need) across the bottom 8%. Lift
   the log clear of it, into the empty space left of the hand tray, so it stops
   hiding the player's own progress. */
@media (pointer: coarse) and (max-height: 440px) {
    .action-log {
        bottom: calc(8% + 6px);
        width: 170px;
        max-height: 30px;
    }
    .log-entry { font-size: 0.62rem; }
}

.action-log::-webkit-scrollbar { width: 4px; }
.action-log::-webkit-scrollbar-track { background: transparent; }
.action-log::-webkit-scrollbar-thumb { background: rgba(201, 168, 76, 0.3); border-radius: 2px; }

/* Help Button */
.help-btn {
    position: absolute;
    z-index: 70;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--cw-bg-card);
    border: 2px solid rgba(201, 168, 76, 0.6);
    color: var(--cw-accent);
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.help-btn:hover {
    background: rgba(201, 168, 76, 0.2);
    border-color: #c9a84c;
    transform: scale(1.1);
}

.login-btn {
    position: absolute;
    z-index: 70;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--cw-bg-card);
    border: 1px solid rgba(201, 168, 76, 0.4);
    color: rgba(201, 168, 76, 0.8);
    font-family: 'Lora', serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.login-btn:hover {
    background: rgba(201, 168, 76, 0.15);
    border-color: #c9a84c;
    color: #c9a84c;
}

/* ===== How to Play Guide ===== */
.help-guide-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cw-bg-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: guideIn 0.25s ease;
}

@keyframes guideIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.help-guide-card {
    position: relative;
    max-width: 880px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 36px 22px;
    background: linear-gradient(145deg, var(--cw-bg-card), var(--cw-bg-card-end));
    border: 2px solid var(--cw-accent);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.guide-close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(250, 243, 224, 0.5);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.guide-close-btn:hover { color: #faf3e0; }

.guide-header {
    text-align: center;
    margin-bottom: 16px;
}

.guide-page-label {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: rgba(201, 168, 76, 0.6);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.guide-header h2 {
    font-family: 'Cinzel', serif;
    color: #c9a84c;
    font-size: 1.6rem;
    margin-top: 4px;
    letter-spacing: 0.03em;
}

.guide-body {
    color: #faf3e0;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 16px;
}

.guide-body p { margin-bottom: 12px; }
.guide-note { color: rgba(250, 243, 224, 0.55); font-size: 0.85rem; }

.guide-species-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.guide-species {
    text-align: center;
    width: 126px;
}

.guide-species img {
    width: 110px;
    height: auto;
    border-radius: 4px;
    border: 2px solid #5c4033;
    cursor: zoom-in;
}

.guide-species span {
    display: block;
    font-size: 0.8rem;
    margin-top: 4px;
    color: rgba(250, 243, 224, 0.7);
}

.guide-species em { color: #c9a84c; font-style: normal; font-weight: 700; }

.guide-arrow {
    color: rgba(201, 168, 76, 0.5);
    font-size: 1.2rem;
    margin-top: -18px;
}

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}

.guide-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.guide-step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.15);
    border: 2px solid #c9a84c;
    color: #c9a84c;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-reqs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.guide-req {
    text-align: center;
}

.guide-req img {
    width: 120px;
    height: auto;
    border-radius: 4px;
    border: 2px solid #2d5016;
    cursor: zoom-in;
}

.guide-req span {
    display: block;
    font-size: 0.8rem;
    margin-top: 4px;
}

.guide-req-plus {
    color: #c9a84c;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: -14px;
}

.guide-card-types {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
}

.guide-type {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.guide-type-swatch {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(250, 243, 224, 0.2);
}

.guide-remedy-table {
    width: 100%;
    margin: 14px 0;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.guide-remedy-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(250, 243, 224, 0.08);
}

.guide-remedy-table td:nth-child(2) {
    text-align: center;
    color: rgba(201, 168, 76, 0.5);
    width: 30px;
}

.guide-trouble-name {
    color: #c45050;
    font-weight: 700;
}

.guide-safe-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px 18px;
    margin: 12px 0;
}

.guide-safe-list > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    width: 150px;
}

.guide-safe-list img {
    width: 72px;
    height: auto;
    border-radius: 4px;
    border: 2px solid #1a2e4a;
    flex-shrink: 0;
    cursor: zoom-in;
}

.guide-safe-list span { font-size: 0.9rem; }

.guide-giddyup {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 8px;
    font-size: 0.9rem;
}

.guide-wild-section {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 12px 0;
}

.guide-wild-img {
    width: 140px;
    height: auto;
    border-radius: 4px;
    border: 2px solid #7a5c1f;
    flex-shrink: 0;
    cursor: zoom-in;
}

.guide-wild-section ul {
    list-style: none;
    padding: 0;
    margin-top: 10px;
}

.guide-wild-section li {
    padding: 4px 0 4px 16px;
    position: relative;
    font-size: 0.9rem;
}

.guide-wild-section li::before {
    content: '\2022';
    position: absolute;
    left: 0;
    color: #c9a84c;
}

.guide-tips {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
}

.guide-tip {
    padding: 10px 14px;
    background: rgba(250, 243, 224, 0.04);
    border-left: 3px solid rgba(201, 168, 76, 0.4);
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
}

.guide-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.guide-prev-btn, .guide-next-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
}

.guide-prev-btn {
    background: transparent;
    border: 1px solid rgba(250, 243, 224, 0.2);
    color: rgba(250, 243, 224, 0.6);
}

.guide-prev-btn:hover {
    border-color: rgba(250, 243, 224, 0.4);
    color: #faf3e0;
}

.guide-next-btn {
    background: var(--cw-accent);
    border: none;
    color: var(--cw-btn-hover-text);
}

.guide-next-btn:hover {
    background: #dfc575;
    transform: translateY(-1px);
}

.guide-dots {
    display: flex;
    gap: 8px;
}

.guide-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(250, 243, 224, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.guide-dot.active {
    background: #c9a84c;
    transform: scale(1.2);
}

.guide-dot:hover { background: rgba(201, 168, 76, 0.6); }

/* Guide Card Lightbox (click-to-zoom) */
.guide-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.guide-lightbox.active {
    opacity: 1;
}

.guide-lightbox img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 12px;
    box-shadow: 0 8px 60px rgba(0, 0, 0, 0.6);
    transform: scale(0.85);
    transition: transform 0.3s ease;
    pointer-events: none;
}

.guide-lightbox.active img {
    transform: scale(1);
}

/* ===== Contextual Explainer Panel ===== */
.explainer-panel {
    position: absolute;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100%;
    background: var(--cw-bg-card-end);
    border-left: 2px solid rgba(201, 168, 76, 0.4);
    z-index: 75;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -8px 0 30px rgba(0,0,0,0.4);
}

.explainer-panel.explainer-open {
    right: 0;
}

.explainer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
    flex-shrink: 0;
}

.explainer-header h3 {
    font-family: 'Cinzel', serif;
    color: #c9a84c;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}

.explainer-close {
    background: none;
    border: none;
    color: rgba(250, 243, 224, 0.5);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.explainer-close:hover { color: #faf3e0; }

.explainer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.explainer-section {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(250, 243, 224, 0.06);
}

.explainer-section:last-child { border-bottom: none; }

.explainer-section h4 {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: rgba(201, 168, 76, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.explainer-section p {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #faf3e0;
    margin-bottom: 6px;
}

.explainer-checklist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
}

.explainer-check {
    font-size: 0.85rem;
    padding: 3px 0;
}

.explainer-check.met { color: #4CAF50; }
.explainer-check.unmet { color: rgba(250, 243, 224, 0.4); }

.check-icon {
    display: inline-block;
    width: 18px;
    text-align: center;
}

.explainer-ready {
    color: #4CAF50 !important;
    font-weight: 700;
}

.explainer-blocked {
    color: #c45050 !important;
}

.explainer-trophies {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.explainer-trophy {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: rgba(250, 243, 224, 0.06);
    border-radius: 4px;
    color: rgba(250, 243, 224, 0.4);
}

.explainer-trophy.done {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.explainer-trophy.current {
    background: rgba(201, 168, 76, 0.15);
    color: #c9a84c;
    border: 1px solid rgba(201, 168, 76, 0.3);
}

.explainer-hand-card {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(250, 243, 224, 0.03);
    border-radius: 6px;
    border-left: 3px solid rgba(250, 243, 224, 0.1);
}

.explainer-hand-card.playable {
    border-left-color: #4CAF50;
    background: rgba(76, 175, 80, 0.06);
}

.explainer-hand-card strong {
    font-size: 0.88rem;
    color: #faf3e0;
}

.card-cat {
    font-size: 0.65rem;
    padding: 1px 6px;
    border: 1px solid;
    border-radius: 3px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(250, 243, 224, 0.5);
    vertical-align: middle;
}

.explainer-hand-card p {
    font-size: 0.8rem;
    margin-top: 3px;
    color: rgba(250, 243, 224, 0.6);
    margin-bottom: 0;
}

.explainer-opponent {
    padding: 8px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(250, 243, 224, 0.04);
}

.explainer-opponent:last-child { border-bottom: none; }

.explainer-opp-trouble {
    color: #c45050;
    font-size: 0.8rem;
}

.explainer-opp-safe {
    color: #5c88c4;
    font-size: 0.8rem;
}

.explainer-opp-hunt {
    color: rgba(250, 243, 224, 0.4);
    font-size: 0.78rem;
}

.explainer-tip-section {
    background: rgba(201, 168, 76, 0.06);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-bottom: none;
}

.explainer-tip-section p {
    color: #c9a84c;
    font-size: 0.88rem;
}

.explainer-full-guide-section {
    text-align: center;
    border-bottom: none;
    padding-top: 8px;
}

.explainer-full-guide-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 20px;
    background: transparent;
    border: 1px solid rgba(201, 168, 76, 0.35);
    color: rgba(201, 168, 76, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.explainer-full-guide-btn:hover {
    background: rgba(201, 168, 76, 0.1);
    border-color: #c9a84c;
    color: #c9a84c;
}

/* Explainer body scrollbar */
.explainer-body::-webkit-scrollbar { width: 4px; }
.explainer-body::-webkit-scrollbar-track { background: transparent; }
.explainer-body::-webkit-scrollbar-thumb { background: rgba(201, 168, 76, 0.2); border-radius: 2px; }

/* Help guide card scrollbar */
.help-guide-card::-webkit-scrollbar { width: 6px; }
.help-guide-card::-webkit-scrollbar-track { background: transparent; }
.help-guide-card::-webkit-scrollbar-thumb { background: rgba(201, 168, 76, 0.3); border-radius: 3px; }

/* First-time welcome styling */
.select-learn-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 24px;
    background: transparent;
    border: 2px solid rgba(201, 168, 76, 0.5);
    color: #c9a84c;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
    display: block;
    width: 100%;
    text-align: center;
}

.select-learn-btn:hover {
    background: rgba(201, 168, 76, 0.12);
    border-color: #c9a84c;
}

.select-back {
    display: block;
    margin: 18px auto 0;
    padding: 6px 10px;
    background: none;
    border: none;
    font-family: 'Lora', serif;
    font-size: 0.85rem;
    color: rgba(250, 243, 224, 0.35);
    cursor: pointer;
    transition: color 0.2s;
}

.select-back:hover {
    color: rgba(250, 243, 224, 0.7);
}

.select-welcome {
    color: rgba(250, 243, 224, 0.5);
    font-size: 0.85rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .select-card { padding: 30px 24px; }
    .select-card h2 { font-size: 1.5rem; }
    .select-buttons { flex-direction: column; gap: 10px; }
    .select-buttons button { padding: 14px 24px; font-size: 1rem; min-height: 48px; }
    .tutorial-banner { max-width: 90%; font-size: 0.8rem; padding: 8px 16px; }
    .action-log { width: 140px; max-height: 60px; font-size: 0.65rem; }
    .log-entry { font-size: 0.65rem; }
    .gameover-card { padding: 28px 24px; min-width: auto; width: 90%; }
    .gameover-card h2 { font-size: 1.5rem; }
    .gameover-stats { flex-wrap: wrap; gap: 12px; }
    .discard-btn, .cancel-btn { padding: 10px 16px; font-size: 0.8rem; min-height: 44px; }
    .action-btn { padding: 10px 16px; font-size: 0.8rem; min-height: 44px; }
    .help-guide-card { padding: 28px 20px 20px; }
    .guide-header h2 { font-size: 1.3rem; }
    .guide-species img { width: 80px; }
    .guide-species { width: 96px; }
    .guide-req img { width: 90px; }
    .guide-prev-btn, .guide-next-btn { padding: 8px 16px; font-size: 0.8rem; }
    .explainer-panel { width: 280px; right: -300px; }
    .help-btn { width: 44px; height: 44px; font-size: 1.1rem; }
}

/* Very small screens */
@media (max-width: 380px) {
    .select-card { padding: 24px 18px; }
    .select-card h2 { font-size: 1.3rem; }
    .action-log { display: none; }
    .opponent-list li { font-size: 0.95rem; }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .tutorial-banner { top: 28%; font-size: 0.75rem; padding: 6px 14px; max-width: 50%; }
    .action-log { max-height: 40px; width: 120px; }
}

