:root {
  color-scheme: dark;
  --ink: #14241c;
  --cream: #f6f1e6;
  --green: #008751;
  --green-deep: #0c3b28;
  --gold: #f0c14d;
  --hibiscus: #d7263d;
  --shadow: 0 18px 50px rgba(16, 24, 20, 0.28);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #e7a15a;
  overflow: hidden;
  touch-action: manipulation;
}

button, input { font: inherit; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}

#top button, #who { pointer-events: auto; }

#who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(246, 241, 230, 0.94);
  color: var(--ink);
  box-shadow: var(--shadow);
}

#face, #mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  background: var(--gold);
}

#face { object-fit: cover; }

#mark {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
}

#pname, #paccount { display: block; }
#pname { font-size: 15px; line-height: 1.1; }
#paccount { font-size: 12px; opacity: 0.68; }

#signin, #mute, .ghost {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

#signin { padding: 8px 12px; }

#mute {
  padding: 8px 12px;
  background: rgba(20, 36, 28, 0.72);
  color: var(--cream);
}

#who { justify-self: start; }
#mute { justify-self: end; }

#score {
  display: flex;
  gap: 8px;
  justify-self: center;
}

#score div {
  min-width: 76px;
  padding: 8px 12px 6px;
  border-radius: 16px;
  background: rgba(20, 36, 28, 0.78);
  color: var(--cream);
  text-align: center;
}

#score b {
  display: block;
  font-size: 28px;
  line-height: 1;
}

#score span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

#pop {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 18%;
  margin: 0;
  transform: translateX(-50%);
  font-size: clamp(42px, 8vw, 84px);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: white;
  text-shadow: 0 6px 0 #0c3b28;
  pointer-events: none;
}

#pop.show { animation: pop 0.55s ease; }

@keyframes pop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

#mama {
  position: fixed;
  z-index: 4;
  left: 16px;
  right: 16px;
  bottom: calc(108px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 0 auto;
  max-width: 720px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(12, 40, 28, 0.88);
  color: var(--cream);
  box-shadow: var(--shadow);
}

#mama span {
  flex: none;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#mama em { font-style: normal; font-size: 16px; }

#actions {
  position: fixed;
  z-index: 4;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}

#kick, #finish {
  min-height: 72px;
  border: 0;
  border-radius: 18px;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}

#kick {
  flex: 1.4;
  background: var(--cream);
  color: var(--ink);
}

#kick.ok { box-shadow: inset 0 0 0 3px var(--gold); }
#kick.hot { background: var(--green); color: white; }

#finish {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(246, 241, 230, 0.38);
  color: white;
}

#finish small { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

#finish.ready {
  background: var(--gold);
  color: #1d1608;
  animation: ready 0.9s ease-in-out infinite;
}

@keyframes ready {
  50% { transform: translateY(-3px); }
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(16, 28, 22, 0.28);
  overflow: auto;
}

#overlay[hidden] { display: none; }

.card {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px 22px 18px;
  border-radius: 28px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2 { margin: 4px 0 8px; letter-spacing: -0.045em; line-height: 0.9; }
h1 { font-size: clamp(64px, 12vw, 92px); }
h2 { font-size: clamp(32px, 6vw, 46px); line-height: 1; }

#lede, .kit, .hint, #rank-line, #phone-best, #board-note, #title-board {
  margin: 0 0 10px;
  line-height: 1.4;
}

.kit { font-weight: 700; }

ul { margin: 0 0 16px; padding-left: 18px; }
li { margin: 6px 0; }

.go, .ghost {
  width: 100%;
  min-height: 52px;
  margin-top: 8px;
}

.go { background: var(--green); color: white; border-radius: 999px; font-size: 18px; }

.ghost {
  background: transparent;
  color: var(--green-deep);
  border: 2px solid rgba(12, 59, 40, 0.2);
}

.hint { opacity: 0.62; font-size: 13px; }

.stat {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 8px;
}

#board {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

#board li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid rgba(20, 36, 28, 0.1);
}

#board i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

#board .mine { font-weight: 800; }

body.menu #mama,
body.menu #actions,
body.menu #pop,
body.menu #score { visibility: hidden; }

@media (pointer: coarse) {
  .hint { display: none; }
}

@media (max-width: 720px) {
  #score div { min-width: 64px; }
  #score b { font-size: 22px; }
  #mute { padding: 8px 10px; font-size: 13px; }
}
