/* ============================================================
   Duet — two phones, one picture. Warm, calm, one-thing-at-a-time.
   ============================================================ */

:root {
  --bg:        #17130f;
  --bg-2:      #0f0c09;
  --panel:     #211a13;
  --panel-hi:  #2b2118;
  --line:      #3a2e21;
  --paper:     #ece4d6;
  --paper-edge:#d8ccb6;

  --text:      #ece1cc;
  --muted:     #9c8b72;
  --faint:     #6f6151;

  --amber:     #e0913a;
  --teal:      #3aa6b9;
  --accent:    var(--amber);

  --btn:       #2a2018;
  --btn-hi:    #36291d;
  --btn-line:  #483a29;
  --danger:    #d8453a;

  --r:         16px;
  --r-sm:      11px;
  --shadow:    0 10px 30px rgba(0,0,0,.45);

  --safe-t:    env(safe-area-inset-top, 0px);
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-l:    env(safe-area-inset-left, 0px);
  --safe-r:    env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex; flex-direction: column;
  min-height: 100%;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}

/* ---------- screen switching ---------- */
.screen { display: none; flex: 1; flex-direction: column; }
body[data-screen="home"]  #home,
body[data-screen="lobby"] #lobby,
body[data-screen="game"]  #game { display: flex; }

/* ---------- shared controls ---------- */
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

.primary, .ghost, .danger {
  border-radius: var(--r-sm);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 16px;
  transition: transform .06s ease, background .15s ease, opacity .15s ease;
  border: 1px solid transparent;
}
.primary:active, .ghost:active, .danger:active { transform: scale(.98); }
.primary { background: linear-gradient(180deg, var(--btn-hi), var(--btn)); border-color: var(--btn-line);
           color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.primary.big, .ghost.big { width: 100%; padding: 16px; font-size: 17px; }
.ghost { background: transparent; border-color: var(--btn-line); color: var(--text); }
.danger { background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.link { background: none; color: var(--muted); padding: 12px; font-size: 15px; }
.block { width: 100%; margin-top: 10px; }

/* ===================== HOME ===================== */
#home { justify-content: center; gap: 18px; padding: 26px 22px; max-width: 460px; width: 100%; margin: 0 auto; }
.hero { text-align: center; margin-bottom: 6px; }
.logo { display: block; margin: 0 auto 10px; filter: drop-shadow(0 6px 16px rgba(0,0,0,.4)); }
h1 { margin: 0; font-size: 40px; letter-spacing: .5px; font-weight: 700; }
.tagline { margin: 8px 0 0; color: var(--muted); line-height: 1.5; font-size: 15.5px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
         padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 9px; }
.field.center { align-items: center; text-align: center; }
.field > label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }

input {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 14px; font-size: 22px; text-align: center;
  letter-spacing: 4px; text-transform: uppercase; font-weight: 700; width: 100%;
}
input::placeholder { color: var(--faint); letter-spacing: 3px; font-weight: 600; }
input:focus { outline: none; border-color: var(--accent); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 14px;
           background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; background: var(--btn); border: 1px solid var(--btn-line);
                  font-size: 24px; font-weight: 600; display: grid; place-items: center; }
.stepper button:active { background: var(--btn-hi); }
.stepper output { min-width: 56px; text-align: center; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

.footnote { text-align: center; color: var(--faint); font-size: 13px; margin: 4px 0 0; }
.hint { color: var(--faint); font-size: 12.5px; margin: 2px 0 0; }

/* ===================== LOBBY ===================== */
#lobby { justify-content: center; align-items: center; gap: 26px; padding: 26px 22px; text-align: center; }
.lobby-top { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.kicker { color: var(--muted); font-size: 14px; margin: 0; }
.code-display { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
                padding: 18px 30px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#code-text { font-size: 46px; font-weight: 800; letter-spacing: 10px; color: var(--accent); padding-left: 10px; }
.copy-hint { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 1px; }

.waiting { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); }
.pulse { width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
         animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(.7); opacity: .4; } 50% { transform: scale(1.1); opacity: 1; } }

/* ===================== GAME ===================== */
#game { padding: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.turn-pill { flex: 1; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 15px;
             background: var(--panel); border: 1px solid var(--line); color: var(--muted);
             text-align: center; transition: background .2s, color .2s, box-shadow .2s; }
body[data-turn="me"]   .turn-pill { background: color-mix(in srgb, var(--accent) 22%, var(--panel));
                                     color: var(--text); border-color: color-mix(in srgb, var(--accent) 60%, transparent);
                                     box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), 0 6px 18px color-mix(in srgb, var(--accent) 18%, transparent); }
.counter { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; color: var(--text); }
.counter .of { color: var(--faint); margin: 0 2px; }
#count-max { color: var(--muted); }
.icon-btn { width: 42px; height: 42px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel);
            font-size: 22px; line-height: 1; color: var(--muted); display: grid; place-items: center; }

.canvas-wrap { flex: 1; position: relative; display: grid; place-items: center; padding: 8px 16px; min-height: 0; }
#board { background: var(--paper); border-radius: 14px; touch-action: none;
         box-shadow: 0 0 0 1px var(--paper-edge), 0 14px 40px rgba(0,0,0,.5);
         transition: box-shadow .25s ease; }
body[data-turn="me"] #board { box-shadow: 0 0 0 2px var(--accent), 0 0 26px color-mix(in srgb, var(--accent) 40%, transparent), 0 14px 40px rgba(0,0,0,.5); }

.canvas-veil { position: absolute; inset: 8px 16px; border-radius: 14px;
               background: rgba(15,12,9,.46); backdrop-filter: blur(1px);
               display: none; place-items: center; pointer-events: none; }
.canvas-veil span { background: rgba(15,12,9,.78); border: 1px solid var(--line); color: var(--text);
                    padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; }
body[data-turn="them"] .canvas-veil,
body[data-turn="waiting"] .canvas-veil { display: grid; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
           padding: 12px 16px calc(12px + var(--safe-b)); transition: opacity .2s ease; }
body:not([data-turn="me"]) .toolbar { opacity: .4; pointer-events: none; }

.swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent;
          box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.25); }
.swatch.is-on { border-color: var(--text); transform: scale(1.12); }

.brushes { display: flex; gap: 6px; }
.brush { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
         display: grid; place-items: center; }
.brush.is-on { border-color: var(--accent); background: var(--panel-hi); }
.brush i { display: block; background: var(--text); border-radius: 50%; }

/* ===================== OVERLAYS ===================== */
.overlay { position: fixed; inset: 0; background: rgba(8,6,4,.6); backdrop-filter: blur(3px);
           display: none; align-items: center; justify-content: center; padding: 24px; z-index: 20; }
.overlay[aria-hidden="false"] { display: flex; }
.overlay#menu { align-items: flex-end; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 24px;
        width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow);
        animation: rise .22s ease; }
.card h2 { margin: 0 0 6px; font-size: 28px; }
#done-sub { color: var(--muted); margin: 0 0 20px; }
.done-actions { display: flex; flex-direction: column; gap: 10px; }
.done-actions .primary, .done-actions .ghost { width: 100%; }

.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0;
         padding: 20px 18px calc(20px + var(--safe-b)); width: 100%; max-width: 460px; box-shadow: var(--shadow);
         animation: rise .22s ease; }
.sheet-row { display: flex; justify-content: space-between; align-items: center;
             padding: 6px 2px 14px; border-bottom: 1px solid var(--line); margin: 0 0 12px; color: var(--muted); }
.sheet-row strong { color: var(--accent); font-size: 20px; letter-spacing: 3px; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
         background: var(--panel-hi); border: 1px solid var(--btn-line); color: var(--text);
         padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 40;
         opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 520px) {
  #game { max-width: 560px; width: 100%; margin: 0 auto; }
}
