/* Shared by the phone and the TV page. Phone-first: readable at arm's length, big tap targets,
   whole-screen layouts in dynamic viewport units, nothing to pinch or zoom. */

:root {
  --bg: #1f1c19;
  --panel: #2b2723;
  --line: #45403a;
  --text: #f3ede4;
  --muted: #b5aca0;
  --accent: #e8b04a;
  --accent-text: #241a08;
  --armed: #f08a3a;
  --danger: #e0685e;
  --good: #6cc488;
  --rule-bg: #f4d77a;
  --rule-text: #2a2108;
  --radius: 14px;
  color-scheme: dark;
}

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

[hidden] {
  display: none !important;
}

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

body.phone {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 22px 0 8px;
}

.brand {
  font-size: 40px;
  letter-spacing: 0.02em;
  margin: 28px 0 22px;
}

.brand.small {
  font-size: 22px;
  margin: 0;
}

.label {
  color: var(--muted);
  font-size: 16px;
}

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

/* ---- controls ------------------------------------------------------------------------------- */

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

button {
  min-height: 48px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--panel);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

button.big {
  min-height: 60px;
  font-size: 20px;
}

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

button.secondary {
  background: var(--panel);
  border-color: #6b6258;
}

button.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  min-height: 44px;
}

/* The first tap of a confirm: the button asks for a second one (KTD4). */
button.armed,
button.quiet.armed {
  background: var(--armed);
  border-color: #ffd0a8;
  color: #1d1208;
  animation: armed 0.9s ease-in-out infinite alternate;
}

@keyframes armed {
  to {
    border-color: var(--armed);
  }
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  animation: none;
}

input {
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 2px solid #6b6258;
  background: #15130f;
  font-size: 22px;
  user-select: text;
  -webkit-user-select: text;
}

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

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

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#reclaim {
  margin-top: 32px;
}

/* ---- screens -------------------------------------------------------------------------------- */

.screen {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 24px;
}

.dock {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.center {
  justify-content: center;
}

.center .message {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  text-align: center;
}

.center .message p {
  font-size: 22px;
  color: var(--muted);
}

.center-text {
  text-align: center;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.message .clock {
  font-size: 34px;
  color: var(--text);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card.building {
  background: var(--accent);
  color: var(--accent-text);
}

.card.building strong {
  font-size: 24px;
}

/* ---- lobby ---------------------------------------------------------------------------------- */

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--panel);
}

.player.is-builder {
  outline: 2px solid var(--accent);
}

.player.is-away .name {
  color: var(--muted);
}

.player .who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player .name {
  font-weight: 700;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.player .tags {
  font-size: 15px;
  color: var(--muted);
}

.player .actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.player .actions button {
  padding: 6px 10px;
  font-size: 16px;
  max-width: 150px;
}

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented button[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper button {
  width: 52px;
  font-size: 24px;
  padding: 0;
}

.stepper span {
  min-width: 72px;
  text-align: center;
  font-weight: 700;
}

.stepper span.pending {
  color: var(--armed);
}

#minutes-set {
  width: 100%;
}

.reason {
  color: var(--rule-bg);
  font-size: 17px;
  text-align: center;
}

.reason:empty {
  display: none;
}

/* ---- the round ------------------------------------------------------------------------------ */

.round-top {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--rule-bg);
  color: var(--rule-text);
}

.rule {
  flex: 1 1 auto;
  padding: 10px 14px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.round-top .clock {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 26px;
  background: #1a1712;
  color: var(--text);
}

.view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.view canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.no-3d {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

/* The guess: pinned to the part of the screen the keyboard leaves (phone.js keeps these
   variables on the visual viewport), with every control at the top. */
#typing {
  top: var(--vv-top, 0px);
  bottom: auto;
  height: var(--vv-height, 100dvh);
}

.typing {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
}

.lock-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
}

/* ---- the unveiling -------------------------------------------------------------------------- */

#unveil-name {
  font-size: 40px;
  margin: 4px 0 14px;
  overflow-wrap: anywhere;
}

.verdict {
  font-size: 28px;
  font-weight: 700;
}

.verdict[data-verdict='true'] {
  color: var(--good);
}

.verdict[data-verdict='false'] {
  color: var(--danger);
}

#unveil-guess {
  margin-top: 6px;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.scores {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 24px 0 0;
}

.scores div {
  flex: 1 1 0;
  padding: 12px 6px;
  border-radius: var(--radius);
  background: var(--panel);
}

.scores dt {
  color: var(--muted);
  font-size: 15px;
}

.scores dd {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
}

.scores dd .of {
  font-size: 0.6em;
}

/* ---- status: the connection banner (net.js) and refusals ------------------------------------ */

.net-banner {
  position: fixed;
  left: 50%;
  top: calc(8px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 18, 16, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
}

.net-banner.blocking {
  top: 40%;
  flex-direction: column;
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 20px;
  text-align: center;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.6); /* dims the stale page behind it */
}

.net-banner button {
  min-height: 52px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.net-banner form {
  display: flex;
  gap: 10px;
  width: min(420px, calc(100vw - 72px)); /* the banner shrinks to its text, so not a percentage */
}

.net-banner form input {
  flex: 1;
  min-width: 0;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(150px + env(safe-area-inset-bottom));
  z-index: 15;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #f3ede4;
  color: #1f1c19;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* While the guess is typed the keyboard covers the bottom: show refusals under the controls. */
body:has(#typing:not([hidden])) .toast {
  top: calc(var(--vv-top, 0px) + 190px);
  bottom: auto;
}
