:root {
  --ink: #241820;
  --cream: #fff6ea;
  --gold: #ffc83d;
  --maroon: #8d2f4a;
  --paper: #fff8ef;
  --share: #ff4f73;
  --good: #1f8a4c;
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #79c0e4;
  overflow: hidden;
  touch-action: none;
}

button, input { font: inherit; color: inherit; }

#app {
  position: fixed;
  inset: 0;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #8ec8ea;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 64px 0 12px;
}

#hud[data-mode="title"],
#hud[data-mode="nick"],
#hud[data-mode="over"] #topbar,
#overlay.nick ~ #hud,
.stat, #clockWrap { }

#app[data-mode="nick"] #topbar,
#app[data-mode="title"] #topbar,
#app[data-mode="over"] #topbar {
  visibility: hidden;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 92px;
  padding: 8px 12px 10px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ink);
}

.stat .k, #wind, #pressure, .eyebrow, .fine {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat strong {
  font-family: "Lilita One", Impact, sans-serif;
  font-size: 32px;
  line-height: 1;
  font-weight: 400;
}

#combo {
  color: var(--maroon);
  font-weight: 800;
}

#wind { color: #1c6ea8; letter-spacing: 0.04em; }
#pressure { color: var(--maroon); letter-spacing: 0.04em; }

#clockWrap {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2a3142, #141820 70%);
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  display: grid;
  place-items: center;
}

#clock {
  font-family: "Lilita One", Impact, sans-serif;
  color: #fff6ea;
  font-size: 32px;
  line-height: 1;
}

#clockWrap.low {
  background: radial-gradient(circle at 40% 35%, #ff6d7d, #9d1838 72%);
  animation: pulse 0.6s ease-in-out infinite;
}

#clockWrap.add { transform: scale(1.08); }

#added {
  position: absolute;
  left: 50%;
  top: 100%;
  margin-top: 4px;
  transform: translateX(-50%);
  font-style: normal;
  font-family: "Lilita One", Impact, sans-serif;
  font-size: 22px;
  color: #b6f25c;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  white-space: nowrap;
}

#added.go { animation: floaty 0.85s ease forwards; }

#banner {
  position: absolute;
  left: 50%;
  top: 23%;
  width: min(92vw, 520px);
  transform: translateX(-50%);
  margin: 0;
  text-align: center;
  font-family: "Lilita One", Impact, sans-serif;
  font-size: clamp(32px, 9vw, 64px);
  line-height: 0.9;
  color: var(--cream);
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  opacity: 0;
}

#banner.show { animation: popbanner 0.95s ease forwards; }

#coach {
  position: absolute;
  left: 14px;
  right: 14px;
  top: calc(112px + env(safe-area-inset-top));
  margin: 0 auto;
  max-width: 420px;
  padding: 10px 14px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 800;
  text-align: center;
}

#coach[hidden] { display: none; }

#mute {
  position: fixed;
  z-index: 6;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: var(--cream);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 20px;
  pointer-events: auto;
}

#mute[aria-pressed="true"] { background: #d7d0c8; }

#overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  padding: calc(8px + env(safe-area-inset-top)) 0 calc(8px + env(safe-area-inset-bottom));
}

#overlay[hidden], #overlay.play { display: none; }
#overlay.nick { justify-content: center; }

.logo-wrap {
  margin: 0 0 auto;
  text-align: center;
  pointer-events: none;
  padding-top: 8px;
}

#overlay.nick .logo-wrap { margin: 0 0 8px; }

.logo {
  margin: 0;
  font-family: "Lilita One", Impact, sans-serif;
  font-size: clamp(64px, 18vw, 108px);
  font-weight: 400;
  line-height: 0.8;
  color: var(--cream);
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  letter-spacing: 0.5px;
}

.logo span { color: #ffd15c; }

.tag, .eyebrow.light {
  margin: 4px 0 0;
  color: var(--cream);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 var(--ink);
}

.sheet {
  pointer-events: auto;
  margin: 10px 12px 12px;
  padding: 14px 14px 16px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: auto;
  max-height: min(78dvh, 720px);
}

#titleView { max-height: min(48dvh, 430px); }
#nickView { max-height: none; }

.sheet h2, .board-title {
  margin: 12px 0 4px;
  font-family: "Lilita One", Impact, sans-serif;
  font-size: 28px;
  font-weight: 400;
}

.eyebrow { margin: 0; color: var(--maroon); }
.lede { margin: 6px 0 10px; font-weight: 700; line-height: 1.35; }
.fine { margin: 0 0 8px; text-transform: none; letter-spacing: 0; font-size: 14px; }

label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: white;
  font-size: 18px;
  font-weight: 700;
}

.error { color: #9d1838; font-weight: 800; min-height: 1.2em; }

.btn {
  display: block;
  width: 100%;
  min-height: 54px;
  margin-top: 8px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 800;
  font-size: 18px;
  background: white;
}

.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn.primary { background: var(--gold); }
.btn.share { background: var(--share); color: white; font-size: 17px; }
.btn.ghost { background: transparent; box-shadow: none; }

.big-score {
  margin: 0;
  font-family: "Lilita One", Impact, sans-serif;
  font-size: clamp(64px, 18vw, 96px);
  line-height: 0.85;
}

.board {
  list-style: none;
  margin: 0;
  padding: 0;
}

.board li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 2px solid rgba(36, 24, 32, 0.08);
  font-weight: 800;
}

.board li b { font-family: "Lilita One", Impact, sans-serif; font-weight: 400; font-size: 20px; }
.board li.you {
  background: #ffe7a3;
  border-radius: 10px;
}
.board .empty { display: block; font-weight: 700; color: #5c5160; }

.share-box {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  border: 2px dashed var(--ink);
  white-space: pre-wrap;
  font-weight: 700;
  user-select: text;
  touch-action: auto;
}

#toast {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 12px 14px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 14px;
  font-weight: 800;
  text-align: center;
}

.boot-error {
  position: fixed;
  z-index: 8;
  left: 16px;
  right: 16px;
  top: 30%;
  padding: 16px;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 16px;
  font-weight: 800;
}

@keyframes popbanner {
  0% { opacity: 0; transform: translateX(-50%) scale(0.6) rotate(-4deg); }
  18% { opacity: 1; transform: translateX(-50%) scale(1.08) rotate(1deg); }
  70% { opacity: 1; transform: translateX(-50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(0.98); }
}

@keyframes floaty {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-28px); }
}

@keyframes pulse {
  50% { transform: scale(1.06); }
}

@media (max-height: 520px) {
  .logo { font-size: 54px; -webkit-text-stroke-width: 5px; }
  #titleView, .sheet { max-height: 70dvh; }
}
