/*
 * Dark, low-glare, thumb-sized. Phones are used in a dim living room while
 * everyone looks at the TV, so nothing here is bright white or small.
 */
:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #151821;
  --surface-2: #1d2130;
  --line: #2a2f40;
  --text: #e8eaf1;
  --muted: #9097ab;
  --accent: #8b9cff;
  --danger: #ff7a7a;
  --ok: #5fd39a;
  --radius: 16px;
  --tap: 60px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;
  cursor: pointer;
}

/* ---- join ---- */

.join {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 40px 20px 24px;
}

.join h1 {
  margin: 0 0 18px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.join label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
}

.code-input,
.name-input,
.field input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  outline: none;
}

.code-input:focus,
.name-input:focus,
.field input:focus {
  border-color: var(--accent);
}

.code-input {
  min-height: 84px;
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  padding-left: 0.35em;
  font-variant-numeric: tabular-nums;
}

.code-input::placeholder {
  color: #3a4052;
}

.name-input {
  font-size: 22px;
}

.error {
  margin: 6px 0 0;
  color: var(--danger);
  font-weight: 600;
}

.fine {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin: 14px 0 0;
}

/* ---- buttons ---- */

.btn {
  --c: var(--accent);
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c) 20%, var(--surface));
  font-size: 20px;
  font-weight: 700;
  transition:
    transform 0.08s,
    background 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active:not(:disabled),
.btn.sent {
  transform: scale(0.97);
  background: color-mix(in srgb, var(--c) 45%, var(--surface));
}

.btn:disabled {
  opacity: 0.32;
  border-color: var(--line);
  background: var(--surface);
  cursor: default;
}

.btn.primary {
  background: color-mix(in srgb, var(--c) 78%, #000);
  color: #0b0d12;
}

.btn.big {
  min-height: 68px;
  font-size: 22px;
  margin-top: 18px;
}

/* ---- header ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffb86b;
  flex: none;
}

.dot.on {
  background: var(--ok);
}

.who {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room {
  color: var(--muted);
  letter-spacing: 0.12em;
  font-weight: 600;
}

.status {
  color: #ffb86b;
  font-weight: 600;
  white-space: nowrap;
}

.leave {
  margin-left: auto;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

/* ---- view ---- */

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px 28px;
  transition: opacity 0.2s;
}

.view.dimmed {
  opacity: 0.45;
  pointer-events: none;
}

.view > .btn {
  width: 100%;
}

.view h1 {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--accent);
}

.text {
  margin: 0;
  font-size: 20px;
  color: var(--text);
  white-space: pre-line;
}

.word {
  --len: 6;
  margin: 10px 0;
  padding: 26px 12px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  /* Heavy capitals run about 0.7em wide; 72px is the page's side padding. */
  font-size: clamp(24px, calc((min(100vw, 520px) - 72px) / (var(--len) * 0.72)), 76px);
  font-weight: 900;
  text-align: center;
  line-height: 1.05;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.note {
  --c: var(--muted);
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border-left: 4px solid var(--c);
  font-size: 18px;
  white-space: pre-line;
}

.label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ---- input ---- */

.field label {
  display: block;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.field .row {
  display: flex;
  gap: 10px;
}

.field input {
  flex: 1;
  min-width: 0;
  font-size: 22px;
}

.field .send {
  flex: none;
}

.shake {
  animation: shake 0.3s;
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* ---- wager ---- */

.wager {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
}

.wager .row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wager-value {
  flex: 1;
  text-align: center;
  font-size: 44px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.nudge {
  width: 68px;
  height: 68px;
  padding: 0;
  font-size: 34px;
  line-height: 1;
}

.wager input[type='range'] {
  width: 100%;
  height: 44px;
  accent-color: var(--accent);
}

/* ---- grid ---- */

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 8px;
}

.opt {
  min-height: var(--tap);
  padding: 8px 10px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.opt.letter {
  padding: 0;
  font-size: 26px;
  aspect-ratio: 1 / 1;
  min-height: 52px;
}

.opt.selected {
  background: var(--c);
  color: #0b0d12;
}

/* ---- timer ---- */

.timer {
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
}

.timer .secs {
  font-size: 54px;
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.timer .bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 6px;
}

.timer .fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.2s linear;
}

.timer.urgent .secs {
  color: var(--danger);
}

.timer.urgent .fill {
  background: var(--danger);
}

.timer.done {
  opacity: 0.5;
}

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 600;
  z-index: 3;
}

.noscript {
  padding: 24px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
