:root {
  --ink: #1d3a4a;
  --cream: #fff8ec;
  --teal: #1f7a7a;
  --teal-dark: #155b5b;
  --sun: #ffcf5a;
  --shadow: 0 6px 18px rgba(20, 50, 70, 0.22);
  color-scheme: light;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8fd3f4;
}

body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  touch-action: none;
  overscroll-behavior: none;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 12px) 0 calc(env(safe-area-inset-left) + 12px);
  pointer-events: none;
}

.pill {
  min-width: 64px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.9);
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: transform 120ms ease-out;
}

.pill.bump { transform: scale(1.18); }
.pill.hurry { color: #b4441f; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
}

.pill.icon {
  pointer-events: auto;
  min-width: 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
}

.pill.icon svg { width: 20px; height: 20px; fill: var(--ink); }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 45, 60, 0.28);
}

.overlay[hidden] { display: none; }

/* The results card sits high, so Lego's nap at the girl's feet stays in view. */
#results {
  place-items: start center;
  padding-top: calc(env(safe-area-inset-top) + 64px);
  background: rgba(20, 45, 60, 0.12);
}

#tower-photo {
  display: block;
  width: 64px;
  height: 0;
  margin: 2px auto 0;
}

.card {
  width: min(340px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 18px;
  border-radius: 24px;
  background: var(--cream);
  box-shadow: var(--shadow);
  text-align: center;
}

/* focused only so screen readers announce it, never ringed */
.card:focus { outline: none; }

.card h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: var(--teal-dark);
}

.card button {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: #e9f1ee;
  border: 2px solid var(--teal); /* 5:1 against the card; a control needs 3:1 to be seen */
  font-size: 15px; /* the icon speaks first; the word stays small */
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.card button.big {
  background: var(--teal);
  color: var(--cream);
  font-size: 18px;
}

.ico { width: 24px; height: 24px; flex: none; fill: currentColor; }
.card button.big .ico { width: 30px; height: 30px; }
#sound-btn.off .waves,
#sound-btn:not(.off) .mute { display: none; }

/* A quiet way to the About page, under the pause menu and the results. */
.about-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin: 4px auto -10px;
  width: max-content;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--teal-dark);
}

/* On the results card a tap anywhere means "play again", so About keeps to
   the bottom-right corner, away from the middle where that tap lands. */
#results-about { margin: 0 -8px -14px auto; }

/* Once the round is over: nothing to pause, no time left. */
#hud.over .clock,
#hud.over #pause-btn { visibility: hidden; }

.card .row { display: flex; gap: 10px; }
.card .row button { flex: 1; }

.final {
  margin: 4px 0;
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.line { margin: 6px 0; font-size: 16px; }

.paws {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
}

.paws svg { width: 40px; height: 40px; fill: var(--teal); }

.again {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
  font-weight: 800;
  color: var(--teal-dark);
  opacity: 0.35;
  transition: opacity 300ms;
}

.again.ready { opacity: 1; }
.again .ico { width: 30px; height: 30px; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
}

/* A short phone (e.g. 320×568): a tighter card without the tower drawing, so
   Lego's nap at the girl's feet stays in view below it. */
@media (max-height: 600px) {
  #results { padding-top: calc(env(safe-area-inset-top) + 58px); }
  #tower-photo { display: none; }
  .card { padding: 14px 16px; }
  .card h2 { font-size: 23px; margin-bottom: 4px; }
  .final { font-size: 46px; }
  .paws { min-height: 36px; }
  .paws svg { width: 34px; height: 34px; }
  .again { margin-top: 8px; }
}

@media (max-height: 420px) {
  #results { padding-top: calc(env(safe-area-inset-top) + 8px); }
  #tower-photo { display: none; }
  .final { font-size: 40px; }
  .card { padding: 12px 14px; }
  .card h2 { font-size: 22px; margin-bottom: 4px; }
  .line { margin: 3px 0; font-size: 14px; }
  .pill { font-size: 18px; padding: 4px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .pill, .again { transition: none; }
  .pill.bump { transform: none; }
}
