:root {
  color-scheme: dark;
  --bg: #1b1f2a;
  --card: #222a38;
  --pink: #ff5fa2;
  --gold: #ffd166;
  --muted: #c9cfdc;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: white;
  font-family: system-ui, sans-serif;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
#game {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  margin: auto;
  overflow: hidden;
  background: var(--bg);
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: max(12px, env(safe-area-inset-top)) 6% max(12px, env(safe-area-inset-bottom));
  background:
    linear-gradient(#1b1f2ae8, #1b1f2ae8),
    var(--tunnel) center/100% 100%;
  gap: 8px;
}
h1 {
  font-size: clamp(28px, 5vh, 44px);
  line-height: 1.02;
  letter-spacing: 1px;
  margin: 0;
  text-align: center;
  font-weight: 900;
}
h1 span {
  color: var(--gold);
}
p {
  margin: 0;
  color: var(--muted);
}
.runners {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}
.runners button {
  width: 50%;
  background: var(--card);
  border: 2px solid #3a4558;
  border-radius: 16px;
  padding: 6px;
  font-weight: 700;
}
.runners svg {
  display: block;
  width: 100%;
  height: clamp(100px, 22vh, 190px);
}
button[aria-pressed="true"] {
  border-color: var(--pink);
  background: #2d2440;
  box-shadow: 0 0 0 1px var(--pink);
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 400px;
}
legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.styles,
.colours {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}
.styles button {
  min-width: 0;
  padding: 2px 0 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--card);
  font-size: clamp(9px, 2.7vw, 12px);
}
.styles svg {
  width: 100%;
  height: 40px;
  display: block;
}
.colours button {
  border: 3px solid var(--bg);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  justify-self: center;
  background: var(--colour);
}
.colours button[aria-pressed="true"] {
  background: var(--colour);
  outline: 3px solid var(--pink);
  box-shadow: none;
}
.primary {
  border: 0;
  border-radius: 32px;
  background: var(--gold);
  color: #1d1b18;
  padding: 14px 20px;
  font-size: 24px;
  font-weight: 900;
  width: 84%;
  max-width: 320px;
  min-height: 52px;
}
.link {
  border: 0;
  background: none;
  text-decoration: underline;
  color: var(--muted);
  padding: 12px;
  min-height: 44px;
}
#play {
  position: absolute;
  inset: 0;
  touch-action: none;
  user-select: none;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(12px + env(safe-area-inset-top)) 12px 8px;
  background: #0006;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#hearts,
#empty-hearts {
  display: flex;
  gap: 4px;
}
#hearts svg,
#empty-hearts svg {
  width: 25px;
  height: 24px;
}
#pause {
  border: 0;
  border-radius: 8px;
  background: #ffffff22;
  width: 40px;
  height: 40px;
  font-size: 22px;
}
.score {
  text-align: right;
  min-width: 90px;
}
.score strong {
  font-size: 20px;
}
.score small {
  display: block;
  font-size: 10px;
  color: var(--gold);
}
.banner {
  position: absolute;
  top: 25%;
  left: 12%;
  width: 76%;
  border: 2px solid #ff4d6d;
  border-radius: 18px;
  background: #1b1f2ae8;
  text-align: center;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.banner strong {
  font-size: 30px;
}
.banner span {
  color: #ffd1dc;
}
.banner small {
  color: var(--muted);
}
.shade {
  position: absolute;
  inset: 0;
  background: #0007;
}
.shade .banner {
  border-color: var(--gold);
}
.banner .primary {
  font-size: 16px;
  width: 100%;
}
#hint {
  position: absolute;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 11px;
  background: #1b1f2aaa;
  padding: 6px;
  pointer-events: none;
}
h2 {
  font-size: clamp(30px, 6vw, 46px);
  color: #ff4d6d;
  margin: 0;
  font-weight: 900;
}
#sad svg {
  height: clamp(110px, 24vh, 200px);
  width: 150px;
}
.result {
  text-align: center;
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  width: 84%;
  max-width: 320px;
}
.result strong {
  font-size: 36px;
}
.result p:last-child {
  color: var(--gold);
  font-weight: 700;
  margin-top: 6px;
}
@media (max-height: 540px) {
  .screen {
    gap: 3px;
  }
  h1 {
    font-size: 24px;
  }
  .runners svg {
    height: 85px;
  }
  .primary {
    padding: 8px;
    font-size: 20px;
  }
  .styles svg {
    height: 28px;
  }
  #sad svg {
    height: 90px;
  }
}

/* Keep the approved 300 by 600 scene proportional on every screen. */
body {
  display: flex;
  align-items: center;
  justify-content: center;
}
#game {
  max-width: none;
  width: min(100vw, 50vh);
  width: min(100vw, 50dvh);
  height: min(100vh, 200vw);
  height: min(100dvh, 200vw);
  margin: 0;
}
#pause {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
#orientation {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 24px;
  font-weight: 700;
}
#hint {
  transition: opacity 1s;
}
#hint.faded {
  opacity: 0;
}
