:root {
  --bg: #0b1d12;
  --panel: #13301e;
  --line: #2b5a3b;
  --text: #f2f7f3;
  --muted: #9fbfa9;
  --accent: #ffd23f;
  --team0: #e63946;
  --team1: #3a86ff;
  --error: #ff7b7b;
  --team: var(--line);
}

* { box-sizing: border-box; }

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

[hidden] { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

/* Join form */

#join { max-width: 440px; margin: 0 auto; }
h1 { margin: 8px 0 4px; font-size: 32px; letter-spacing: .5px; }
.lead { margin: 0 0 20px; color: var(--muted); }

.field { display: block; margin: 0 0 16px; padding: 0; border: 0; }
.field > span, .field > legend { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; padding: 0; }

input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 18px; /* below 16px iOS zooms the page on focus */
}
input:focus { outline: none; border-color: var(--accent); }
#room { text-transform: uppercase; letter-spacing: 6px; font-weight: 700; }

.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: 0 0 0 2px var(--line);
  background: var(--c);
  padding: 0;
  cursor: pointer;
}
.swatch[aria-checked="true"] { border-color: var(--bg); box-shadow: 0 0 0 3px var(--accent); }

button { font: inherit; color: inherit; }
.primary {
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #1d1600;
  font-size: 20px;
  font-weight: 800;
}
.primary:disabled { opacity: .6; }
.error { min-height: 1.4em; color: var(--error); font-weight: 600; }

/* Controller */

#pad {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--team);
  font-weight: 700;
  transition: background .3s;
}
.board { display: flex; gap: 10px; align-items: baseline; font-variant-numeric: tabular-nums; }
.board b { font-size: 20px; }
.phase { margin: 0; text-align: center; color: var(--muted); }
.mystats {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 2px solid var(--accent);
  text-align: center;
  font-weight: 700;
}

.stick-zone {
  position: relative;
  flex: 1;
  min-height: 180px;
  border: 2px dashed var(--line);
  border-radius: 20px;
  touch-action: none;
}
.stick-base {
  position: absolute;
  left: 50%; top: 50%;
  width: 140px; height: 140px;
  margin: -70px 0 0 -70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  border: 2px solid rgba(255, 255, 255, .25);
  opacity: .5;
  pointer-events: none;
}
.stick-zone.active .stick-base { opacity: 1; }
.stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 64px; height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: var(--text);
}
.hint {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.stick-zone.active .hint { visibility: hidden; }

.kick {
  height: 26vh;
  min-height: 110px;
  border: 0;
  border-radius: 24px;
  background: var(--accent);
  color: #1d1600;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 4px;
  touch-action: none;
  box-shadow: 0 6px 0 #b8901a;
}
.kick.down { transform: translateY(4px); box-shadow: 0 2px 0 #b8901a; }

@media (orientation: landscape) and (max-height: 520px) {
  #pad {
    display: grid;
    grid-template-columns: 3fr 2fr;
    grid-template-rows: auto auto auto 1fr;
  }
  .status, .phase, .mystats { grid-column: 1 / -1; }
  .stick-zone, .kick { grid-row: -2; }
  .kick { height: auto; }
}

.conn {
  position: fixed;
  left: 16px; right: 16px; top: max(16px, env(safe-area-inset-top));
  padding: 12px;
  border-radius: 12px;
  background: #3a2a00;
  color: var(--accent);
  text-align: center;
  font-weight: 700;
}

/* Reward */

.reward {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .7);
}
.reward-card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border-radius: 20px;
  background: var(--panel);
  text-align: center;
}
.reward-code {
  margin: 16px 0 24px;
  padding: 14px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 2px;
  user-select: all;
  -webkit-user-select: all;
}
