/* Base styles: plain, dark, readable in a dim restaurant. P4 adds tokens.css, theme.css and
   motion.css on top and restyles. Animate only transform and opacity. */

:root {
  --bg: #14111d;
  --bg-raised: #201b2d;
  --bg-sunk: #0e0c15;
  --line: #3a3350;
  --text: #f5f1fa;
  --muted: #c4bad6;
  --accent: #ffb547;
  --accent-text: #1a1206;
  --danger: #ff6b6b;
  --heat-1: #4cc9f0;
  --heat-2: #ffb547;
  --heat-3: #ff7a9c;
  --heat-4: #ff5a3d;
  --radius: 16px;
  --gap: 12px;
  --pad: 16px;
  --tap: 52px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 8px;
}

p {
  margin: 0 0 10px;
}

.loading {
  padding: 40vh var(--pad) 0;
  text-align: center;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 16px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.screen {
  padding: var(--pad);
  padding-top: calc(var(--pad) + env(safe-area-inset-top));
}

.scorebar + .screen {
  padding-top: var(--pad);
}

.screen-title {
  font-size: 26px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 20px;
  margin-top: 20px;
}

.empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* Layout helpers */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-top: 16px;
}

.row {
  display: flex;
  gap: var(--gap);
  margin-top: var(--gap);
}

.row > * {
  flex: 1 1 0;
  min-width: 0;
}

.row:empty {
  display: none;
}

/* Buttons */
.btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tap);
  width: 100%;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 18px;
  font-weight: 650;
  color: var(--text);
  background: var(--bg-raised);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 120ms var(--ease), opacity 120ms var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:focus-visible,
.topic:focus-visible,
.dial-step:focus-visible,
.badge:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-secondary {
  border-color: var(--line);
}

.btn-secondary[style*='--player'] {
  border-color: var(--player);
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
  font-weight: 550;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-option {
  align-items: flex-start;
  text-align: left;
  border-color: var(--line);
  font-weight: 550;
}

.btn-hint {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.85;
}

.btn-primary .btn-hint {
  opacity: 0.8;
}

.icon-btn {
  appearance: none;
  flex: 0 0 var(--tap);
  width: var(--tap);
  height: var(--tap);
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

/* Forms */
.field {
  border: 0;
  margin: 0 0 18px;
  padding: 0;
}

.field-label {
  display: block;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 8px;
  padding: 0;
}

.field-note {
  margin-top: -10px;
  font-size: 15px;
  color: var(--muted);
}

.text-input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg-sunk);
  color: var(--text);
  font: inherit;
  font-size: 18px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.text-input {
  resize: vertical;
}

.form-error {
  color: var(--danger);
  font-weight: 600;
  min-height: 0;
}

.form-error:empty {
  display: none;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment {
  flex: 1 1 40%;
  position: relative;
}

.segment input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.segment input:checked + span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.segment input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.switch-text {
  display: flex;
  flex-direction: column;
}

.switch-label {
  font-weight: 650;
}

.switch-hint {
  font-size: 15px;
  color: var(--muted);
}

.switch {
  appearance: none;
  flex: 0 0 auto;
  width: 56px;
  height: 32px;
  border-radius: 16px;
  background: var(--line);
  position: relative;
  cursor: pointer;
}

.switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 160ms var(--ease);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(24px);
}

.switch:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(8 6 12 / 0.78);
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom));
}

.sheet {
  width: 100%;
  max-width: 520px;
  padding: 20px var(--pad);
  border-radius: 22px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.sheet.stack {
  margin-top: 0;
}

/* Toast (event feedback until P4's animations) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}

.toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

.player-name {
  color: var(--player);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
