/* Devil's Codename web: same palette and shapes as the iOS app (Theme.swift). */
:root {
  --bg: #120f14;          /* 0.07 0.06 0.08 */
  --card: #211c24;        /* 0.13 0.11 0.14 */
  --card-raised: #2e2630; /* 0.18 0.15 0.19 */
  --ember: #ff5c33;       /* 1.0 0.36 0.20 */
  --gold: #ffc24a;        /* 1.0 0.76 0.29 */
  --cold: #5c8cf2;        /* 0.36 0.55 0.95 */
  --text: #ffffff;
  --dim: rgba(255, 255, 255, 0.6);
  --faint: rgba(255, 255, 255, 0.08);
  --success: #59d98c;
  --danger: #ff6b6b;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.noscript { padding: 24px; text-align: center; color: var(--dim); }

h1, h2, h3 { margin: 0; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.danger { color: var(--danger); }
.gold { color: var(--gold); }
.row { display: flex; gap: 12px; align-items: center; }
.row > .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

/* Home header */
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; }
.brand img { height: 84px; width: auto; }
.brand h1 {
  font-size: 34px; font-weight: 900; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--gold), var(--ember));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card h3 { font-size: 17px; font-weight: 700; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--dim); }

/* Inputs */
input[type=text] {
  width: 100%;
  font: inherit; font-size: 17px; /* 16px+ keeps iOS Safari from zooming */
  color: var(--text);
  background: var(--card-raised);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
}
input[type=text]:focus { border-color: rgba(255, 92, 51, 0.6); }
input::placeholder { color: rgba(255, 255, 255, 0.35); }
input.code { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* Buttons */
button {
  font: inherit; font-weight: 600; font-size: 16px;
  color: var(--text); border: 0; cursor: pointer;
  border-radius: 14px; padding: 14px 16px;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.35; cursor: default; }
.btn-primary { background: var(--ember); width: 100%; }
.btn-secondary { background: var(--card-raised); width: 100%; }
.btn-join { background: rgba(255, 92, 51, 0.5); padding: 13px 18px; }
.btn-link { background: none; color: var(--gold); padding: 8px; font-size: 15px; }
.btn-icon { width: 56px; flex: none; background: var(--ember); font-size: 20px; padding: 12px 0; }
.btn-small { padding: 8px 12px; font-size: 14px; border-radius: 10px; background: var(--card-raised); }

/* Room code */
.code-big {
  font: 900 56px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 8px; color: var(--gold); text-align: center; user-select: all;
}

/* Scoreboard */
.score-row { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.dot.away { background: #8a8a8a; }
.score-row .name.me { color: var(--gold); font-weight: 700; }
.score-row .pts { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--dim); background: var(--faint); border-radius: 99px; padding: 2px 7px;
}

/* Event banner */
.event {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(255, 92, 51, 0.14); border-radius: 14px; padding: 14px; font-size: 15px;
  animation: drop 0.35s ease;
}
.event::before { content: "🔥"; }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Header */
.header { text-align: center; padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.header h2 { font-size: 24px; font-weight: 900; }

/* Secret word */
.secret { background: var(--card-raised); border-radius: var(--radius); padding: 20px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.secret .word { font-size: 40px; font-weight: 900; color: var(--gold); font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif; overflow-wrap: anywhere; }

/* Press and hold to peek */
.peek {
  background: var(--card-raised); border-radius: var(--radius); padding: 28px 16px; text-align: center;
  color: var(--dim); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer;
}
.peek .hand { font-size: 28px; display: block; margin-bottom: 8px; }

/* Hints */
.hint { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; animation: drop 0.35s ease; }
.hint .top { display: flex; justify-content: space-between; gap: 12px; }
.hint .text { font-weight: 600; overflow-wrap: anywhere; }
.hint .pct { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--dim); }
.hint .pct.hit { color: var(--ember); }
.bar { position: relative; height: 10px; border-radius: 99px; background: var(--faint); overflow: visible; }
.bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; width: 0; transition: width 0.6s ease-out; }
.bar .fill.hit { box-shadow: 0 0 10px rgba(255, 92, 51, 0.8); }
.bar .tick { position: absolute; top: -2px; bottom: -2px; width: 2px; background: rgba(255, 255, 255, 0.5); }

/* Spinner */
.spin {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255, 194, 74, 0.25); border-top-color: var(--gold);
  animation: rot 0.8s linear infinite;
}
.btn-icon .spin { margin: 0 auto; border-color: rgba(255, 255, 255, 0.3); border-top-color: #fff; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Guesses */
.guess-row { display: flex; justify-content: space-between; }
.guess-row .ok { color: var(--success); }
.guess-row .pass { font-style: italic; color: var(--dim); }
hr { border: 0; border-top: 1px solid var(--faint); margin: 2px 0; width: 100%; }

/* Standings */
.standing { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.standing .rank { width: 32px; text-align: center; }
.standing .pts { margin-left: auto; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Stepper */
.stepper { display: flex; align-items: center; justify-content: space-between; }
.stepper .btns { display: flex; background: var(--card-raised); border-radius: 10px; overflow: hidden; }
.stepper .btns button { background: none; border-radius: 0; padding: 6px 16px; font-size: 20px; }
.stepper .btns button + button { border-left: 1px solid rgba(255, 255, 255, 0.12); }

/* How to play */
.step { display: flex; gap: 14px; }
.step .icon { font-size: 22px; width: 28px; text-align: center; flex: none; }
.step h3 { margin-bottom: 4px; }

/* Handoff */
.handoff { text-align: center; align-items: center; padding: 28px 16px; }
.handoff h2 { font-size: 28px; font-weight: 900; }

/* Dialog */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; animation: fade 0.15s ease; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sheet h3 { text-align: center; }
.btn-danger { background: rgba(255, 107, 107, 0.2); color: var(--danger); width: 100%; }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--card-raised); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 20; animation: fade 0.2s ease;
}
.footer { text-align: center; font-size: 12px; color: rgba(255, 255, 255, 0.35); }

/* Difficulty picker */
.segmented { display: flex; background: var(--card-raised); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; background: none; border-radius: 9px; padding: 9px 0; font-size: 15px; color: var(--dim); }
.segmented button.on { background: var(--ember); color: #fff; }
.header .badge { vertical-align: 1px; }

/* Devil's Pass supporter flair next to a name */
.flair { font-size: 14px; line-height: 1; }
.flair.scorching { filter: drop-shadow(0 0 4px #ffc24a) saturate(1.4); }

/* Guess history */
.header .btn-small { margin-top: 10px; align-self: center; width: auto; border-radius: 99px; padding: 6px 14px; font-size: 14px; color: var(--gold); }
.sheet.history { max-height: 85vh; }
.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.h-turn { background: var(--card-raised); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.h-head { display: flex; flex-direction: column; gap: 2px; }
.h-word { font-size: 20px; font-weight: 800; color: var(--gold); overflow-wrap: anywhere; }
.h-word.dim { color: var(--dim); font-size: 17px; }
.h-cycle { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--faint); }
.h-hints { display: flex; flex-wrap: wrap; gap: 6px; }
.h-hint { background: var(--faint); border-radius: 99px; padding: 3px 9px; font-size: 13px; }
.h-hint b { color: var(--dim); font-weight: 700; }
.h-hint.hit b { color: var(--gold); }

/* Hint timer */
.clock { display: flex; flex-direction: column; gap: 6px; }
.clock-text { font-size: 14px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.clock-bar { height: 6px; border-radius: 99px; background: var(--faint); overflow: hidden; }
.clock-fill { height: 100%; background: var(--gold); border-radius: 99px; transition: width 0.25s linear; }
.clock.low .clock-text { color: var(--danger); }
.clock.low .clock-fill { background: var(--danger); }
.hint.timeout .text { color: var(--dim); font-style: italic; }

/* Difficulty slider */
.bar-slider .bar-value { color: var(--gold); font-variant-numeric: tabular-nums; }
.bar-slider input[type=range] { width: 100%; accent-color: var(--ember); height: 28px; }
