:root {
  color-scheme: light;
  --ink: #1d2a31;
  --muted: #677178;
  --panel: rgba(255, 255, 255, 0.86);
  --line: #40b6ff;
  --danger: #d04840;
  --gold: #f5b943;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 244, 211, 0.72), transparent 34%),
    linear-gradient(135deg, #d7eef2 0%, #f3eedc 45%, #e9eef3 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: #243944;
  color: #fff;
  cursor: pointer;
  font: 800 14px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  min-height: 42px;
  padding: 0 16px;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}

button:hover {
  background: #17262f;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.shell {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  padding: 14px;
}

.game-wrap {
  aspect-ratio: 9 / 16;
  background: #eaf6fb;
  border: 1px solid rgba(29, 42, 49, 0.12);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(47, 65, 71, 0.24);
  max-height: min(960px, calc(100vh - 28px));
  max-width: min(540px, calc(100vw - 28px));
  overflow: hidden;
  position: relative;
  width: min(540px, calc((100vh - 28px) * 0.5625));
}

#game {
  display: block;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
  width: 100%;
}

.hud {
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.66));
  border-bottom: 1px solid rgba(29, 42, 49, 0.1);
  display: flex;
  justify-content: space-between;
  left: 0;
  min-height: 72px;
  padding: 14px 18px 12px;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 3;
}

.eyebrow {
  color: var(--danger);
  display: block;
  font: 900 12px/1.1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  margin-bottom: 4px;
}

#statusText {
  display: block;
  font: 900 24px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
}

.meters span {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(29, 42, 49, 0.1);
  border-radius: 8px;
  color: var(--ink);
  font: 800 13px/1 Inter, sans-serif;
  min-width: 80px;
  padding: 7px 9px;
}

.controls {
  bottom: 14px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  left: 14px;
  position: absolute;
  right: 14px;
  z-index: 3;
}

.controls button {
  background: rgba(29, 42, 49, 0.86);
  box-shadow: 0 10px 24px rgba(26, 39, 45, 0.16);
  min-width: 0;
}

.overlay {
  align-items: center;
  background: rgba(239, 247, 249, 0.88);
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding: 34px;
  position: absolute;
  text-align: center;
  z-index: 4;
}

.overlay.hidden {
  display: none;
}

.title-word {
  color: #1e343d;
  font: 950 clamp(54px, 16vw, 82px)/0.9 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  margin: 0;
  text-shadow: 0 8px 20px rgba(31, 54, 63, 0.12);
}

#overlayMessage {
  color: #2b444f;
  font: 950 30px/1.05 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  margin: 24px 0 18px;
}

.primary {
  background: linear-gradient(180deg, #ffd865, #f4a820);
  box-shadow: 0 16px 30px rgba(196, 128, 20, 0.28);
  color: #442c05;
  font-size: 18px;
  min-height: 54px;
  padding: 0 34px;
}

.primary:hover {
  background: linear-gradient(180deg, #ffe07a, #f0a11b);
}

@media (max-width: 460px) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    border: 0;
    border-radius: 0;
    max-height: 100vh;
    max-width: 100vw;
    width: min(100vw, 56.25vh);
  }

  .hud {
    min-height: 64px;
    padding: 12px 14px 10px;
  }

  #statusText {
    font-size: 21px;
  }

  .controls {
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
  }

  button {
    font-size: 13px;
    min-height: 40px;
    padding: 0 10px;
  }
}
