/* =============================================
   DRAW GAME - draw.css
   UI redesigned: Light Cartoon / Candy Cloud (orange accent: colours live in the --fj-* block of draw/index.html)
   All styles now live in index.html <style> block (Tailwind-based).
   This file is kept as a thin shim so the <link> tag doesn't 404.
   ============================================= */

/* Global reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    /* overflow:hidden handled per-section in index.html */
}

/* =============================================
   RELAY MODE (🔁 ส่งต่อ, 2026-09-24 draw modes step 5) - public/draw/relay.js
   Kept here rather than in index.html's <style>: this file already ships with
   the page and nothing else lives in it. Everything is scoped under #relay
   (or a relay-* class), so no classic screen changes. This file is linked
   BEFORE index.html's <style>, so every rule that overrides a classic one
   uses the #relay id to win on specificity, not on order.
   Phone first: 360x640 must show the whole draw step - canvas, colours,
   tools and the send button - without scrolling (qa/draw-relay.mjs).
   ============================================= */

/* Lobby rows a relay does not use. A class of its own, not .hidden: those
   rows have other owners toggling .hidden, and taking this off must hand each
   back exactly as its owner left it (relay.js relayRestoreLobby). */
.relay-off { display: none !important; }
.relay-mode-hint { font-style: normal; opacity: .9; padding: 2px 4px; line-height: 1.5; overflow-wrap: anywhere; }
.relay-notice {
    padding: 10px 14px; border-radius: 14px; background: #FFF7ED; color: #9A3412;
    font-size: 13px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere;
}

#relay {
    width: min(100%, 560px); margin: 0 auto; padding: 0 16px;
    gap: 8px;
    /* dvh: the part of the screen really visible under a phone's URL bar */
    min-height: 100dvh;
}
@media (max-width: 480px) { #relay { padding: 0 12px; } }

#relay .relay-top {
    position: sticky; top: 0; z-index: 6;
    display: flex; align-items: center; gap: 8px;
    min-height: 48px; padding: 2px 0;
    background: rgba(255,248,240, .96); border-bottom: 2px solid #FFE3C7;
}
#relay .relay-step-label {
    flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 14px; font-weight: 700; color: #2A2118;
}
#relay .relay-chip {
    flex: 0 0 auto; padding: 3px 8px; border-radius: 9999px;
    background: rgba(var(--fj-brand-rgb), .15); color: var(--fj-brand-text); font-size: 12px; font-weight: 700;
}
#relay .relay-timer {
    flex: 0 0 auto; min-width: 44px; text-align: right;
    font-size: 18px; font-weight: 800; color: #2A2118; font-variant-numeric: tabular-nums;
}
#relay .relay-timer.urgent { color: #dc2626; }
#relay .relay-leave-btn {
    flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 0 10px;
    border: 2px solid rgba(239, 68, 68, .35); border-radius: 9999px; background: #fff;
    color: #b91c1c; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---- one step ---- */
#relay .relay-task { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; }
#relay .relay-instruction { margin-top: 4px; font-size: 15px; font-weight: 600; color: #4A3B2E; }
#relay .relay-fallback {
    padding: 6px 10px; border-radius: 10px; background: #FFF7ED; color: #9A3412;
    font-size: 12px; line-height: 1.45; overflow-wrap: anywhere;
}
/* Two lines at most; a tap shows the rest (relay.js toggles .expanded). */
#relay .relay-prompt {
    font: 700 18px/1.35 'Noto Sans Thai', sans-serif; color: var(--fj-brand-text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere; cursor: pointer;
}
#relay .relay-prompt.expanded { -webkit-line-clamp: unset; }
#relay .relay-image-box { border: 2px solid #FFE3C7; border-radius: 14px; overflow: hidden; background: #fff; }
#relay .relay-image-box img {
    display: block; width: 100%; aspect-ratio: 8 / 5; max-height: 45dvh;
    object-fit: contain; background: #fff;
}
#relay .relay-image-empty {
    display: flex; align-items: center; justify-content: center;
    aspect-ratio: 8 / 5; max-height: 45dvh; background: #F3ECE4; color: #7A6A5A; font-weight: 600;
}
/* Keyboard up: the picture shrinks but stays in view, the chip makes room. */
#relay.kb-open .relay-image-box img,
#relay.kb-open .relay-image-empty { max-height: 26dvh; }
#relay.kb-open .relay-top .relay-chip { display: none; }
/* 16px: iOS Safari zooms the page into any smaller input it focuses. */
#relay .relay-text-box textarea {
    width: 100%; padding: 10px 12px; resize: none;
    font-size: 16px; line-height: 1.4; color: #2A2118;
    background: #fff; border: 2px solid #FFE3C7; border-radius: 14px;
}
#relay .relay-text-box textarea:focus { border-color: var(--fj-brand); outline: none; }
#relay .relay-text-meta { text-align: right; font-size: 12px; color: #4A3B2E; }

/* The send bar sticks to the bottom of the screen, so it is on screen at
   360x640 whatever is above it. */
#relay .relay-actions {
    position: sticky; bottom: 0; z-index: 5; margin-top: auto;
    display: flex; gap: 8px;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,248,240, .96);
}
#relay .relay-actions button { min-height: 52px; justify-content: center; }
#relay .relay-actions #btnRelaySubmit { flex: 1 1 auto; font-size: 16px; }
#relay #btnRelayUndo,
#relay #btnRelayRedo { flex: 0 0 52px; padding: 0; font-size: 22px; }
#relay #btnRelayRedo:disabled { opacity: .45; }
#relay #btnRelaySuggest { flex: 0 0 auto; padding: 0 14px; }

/* ---- the borrowed canvas (a draw step) ---- */
#relay .relay-canvas-slot { width: 100%; }
#relay .canvas-area { flex: none; min-width: 0; overflow: visible; background: transparent; }
/* Shrinks in width AND height together, so a short screen never distorts it
   and never pushes the tools off the bottom. A shadow, not a border: a border
   would shift getCanvasCoords by its width. */
#relay #drawCanvas {
    display: block; margin: 0 auto; aspect-ratio: 8 / 5; height: auto; max-height: none;
    /* 376, was 330 (2026-09-28): the tools take a second 44px row since
       เส้นตรง/วงกลม joined them, and the canvas gives it back.
       max(280px, ...) (M1/D2, 2026-10-04): on a screen shorter than 376px
       (a phone on its side) the sum went negative and the canvas was 0 px
       wide; it never gets below 280 px (a page that is taller than the
       window just scrolls: the send bar and the top bar are sticky). */
    width: min(100%, max(280px, calc((100dvh - 376px) * 1.6)));
    touch-action: none; border-radius: 10px; box-shadow: 0 0 0 2px #FFE3C7;
}
/* The stage that app.js's layout makes a size container on a wide or a short landscape window is a plain block here. */
#relay .canvas-stage { display: block; flex: none; min-height: 0; container-type: normal; }
#relay .draw-tools { padding: 6px 0 0; gap: 4px; background: transparent; border-top: none; }
/* One row of 44px colours, scrolled sideways; the faded edge says there is more. */
#relay .colors-row {
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 2px;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
    mask-image: linear-gradient(90deg, #000 88%, transparent);
}
#relay .color-btn { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; scroll-snap-align: start; }
#relay .color-btn:hover { transform: none; }
/* 2026-10-05: the outline/solid switch and the brush preview lead the colour row; both stay 44px and never shrink. */
#relay .shape-fill-btn, #relay .colors-row > .brush-preview { flex: 0 0 44px; }
#relay .colors-row { scroll-padding-left: 52px; }
/* No scale-up when picked: a grown button would overflow the row. */
#relay .color-btn.active { transform: none; box-shadow: inset 0 0 0 3px #2A2118, inset 0 0 0 5px #fff; }   /* M8: dark ring + white ring reads on every swatch (the orange one vanished on orange) */
/* Pen, eraser, fill, line, circle (one row), then three sizes and clear:
   nine 44px icons in two rows (2026-09-28: seven fitted one row; nine at
   44px do not fit 336px, and a row that scrolls sideways hid "ล้าง"). The
   size group carries an inline gap/margin, hence the !important. */
#relay .tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
#relay .tool-group { flex: 1 0 100%; justify-content: space-between; }
#relay .tools-row > div { gap: 2px !important; margin-left: 0 !important; }
#relay .tool-btn,
#relay .size-btn,
#relay .btn-clear {
    flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0;   /* icon only: the word stays in the DOM, the title names it */
    box-shadow: none;
    overflow: hidden;   /* an icon font that has not loaded shows its ligature name: keep it in the button */
}
#relay .tool-btn .material-symbols-outlined,
#relay .btn-clear .material-symbols-outlined { font-size: 22px !important; }
#relay .size-btn[data-size="4"]  { font-size: 8px; }
#relay .size-btn[data-size="10"] { font-size: 13px; }
#relay .size-btn[data-size="20"] { font-size: 20px; }
#relay .size-btn[data-size="32"] { font-size: 26px; }
/* D6 (2026-10-04): clear in the far corner of the row, away from the sizes (undo is in the send bar here). */
#relay #btnClearCanvas { margin-left: auto; }
/* Undo lives in the send bar here (#btnRelayUndo). */
#relay #btnUndo, #relay #btnRedo { display: none; }

/* ---- sent / watching ---- */
#relay .relay-wait {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    margin-top: 12px; padding: 24px 12px; text-align: center;
    background: #fff; border: 2px solid #FFE3C7; border-radius: 24px;
}
#relay .relay-wait h3 { font-size: 22px; font-weight: 800; color: #16a34a; }
#relay .relay-wait p { font-size: 14px; line-height: 1.5; color: #4A3B2E; overflow-wrap: anywhere; }
#relay .relay-mine-preview { width: 100%; }
#relay .relay-mine-preview img { display: block; margin: 0 auto; max-width: 100%; max-height: 30dvh; border-radius: 12px; border: 2px solid #FFE3C7; }

/* ---- the 2 s card between steps ---- */
.relay-intro {
    position: fixed; inset: 0; z-index: 60;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 24px; text-align: center; background: rgba(255,248,240, .97);
}
.relay-intro-icon { font-size: 64px; line-height: 1; }
.relay-intro-head { font-size: 26px; font-weight: 800; color: var(--fj-brand-text); }
.relay-intro-line { font-size: 18px; font-weight: 600; color: #2A2118; overflow-wrap: anywhere; }

/* ---- the album ---- */
#relay .relay-album { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; }
#relay .relay-album-title { margin-top: 6px; font-size: 18px; font-weight: 800; color: #2A2118; overflow-wrap: anywhere; }
#relay .relay-feed { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
#relay .relay-card {
    display: flex; flex-direction: column; gap: 6px; min-width: 0;
    padding: 8px 10px; background: #fff; border: 2px solid #FFE3C7; border-radius: 16px;
}
#relay .relay-card-author { font-size: 13px; font-weight: 600; color: #4A3B2E; overflow-wrap: anywhere; }
#relay .relay-bubble {
    padding: 10px 12px; border-radius: 14px; background: #FFF4E8;
    font: 700 18px/1.4 'Noto Sans Thai', sans-serif; color: #2A2118; overflow-wrap: anywhere;
}
#relay .relay-card-img { display: block; width: 100%; aspect-ratio: 8 / 5; object-fit: contain; background: #fff; border-radius: 10px; }
#relay .relay-blank { padding: 16px; border-radius: 10px; background: #F3ECE4; color: #7A6A5A; text-align: center; font-weight: 600; }
#relay .relay-pop { animation: relay-pop .35s ease-out; }
@keyframes relay-pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #relay .relay-pop { animation: none; } }
#relay .relay-album-bar {
    position: sticky; bottom: 0; z-index: 5; margin-top: auto;
    display: flex; flex-direction: column; gap: 6px;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,248,240, .96);
}
#relay .relay-album-bar .waiting-text { margin: 0; text-align: center; overflow-wrap: anywhere; }
#relay .relay-album-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
#relay .relay-album-buttons > button { flex: 1 1 120px; min-height: 48px; justify-content: center; }

/* ---- results: one tall picture per chain ---- */
.gallery-card.is-chain .gallery-thumb img { object-fit: cover; object-position: top; }

/* =============================================
   TEAM SCORING RULE + GAVE-UP SLOT (2026-09-27)
   ============================================= */
/* The team lobby's "how a side scores" box (index.html #teamScoringRule).
   Upright, 12px, two short lines that wrap anywhere: the .difficulty-hint
   look (11px italic at .75 opacity) was too faint for a rule people argue
   about. overflow-wrap keeps it inside a 360 px screen. */
.team-scoring-rule {
    margin-top: 6px; padding: 8px 10px; border-radius: 12px;
    background: #FFF7ED; color: #7C2D12;
    font-size: 12px; line-height: 1.5; overflow-wrap: anywhere;
}
.team-scoring-rule .tsr-line { display: block; }
.team-scoring-rule .tsr-line + .tsr-line { margin-top: 2px; }
/* A give-up's slot on the scoreboard: grey, not the green of a right answer
   (.score-item.guessed). Two classes, so it wins over index.html's
   .score-item whatever the order the two stylesheets load in. */
.score-item.gave-up { border-color: #D1D5DB; background: #F3F4F6; }
