:root {
  --paper: #f8efcf;
  --ink: #17343b;
  --olive: #59764f;
  --grass: #7fb56c;
  --grass-dark: #57824a;
  --sand: #d6bd7f;
  --sea: #7ec7da;
  --panel: rgba(250, 244, 224, 0.92);
  --shadow: rgba(26, 40, 43, 0.18);
  --yellow: #f7d861;
  --red: #e5674e;
  --blue: #57b8db;
  --white: #fffef9;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.72), transparent 32%),
    linear-gradient(180deg, #bfe6ef 0%, #87c8d5 28%, #5ea7b8 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 18%, rgba(255,255,255,0.85) 0 4%, transparent 4.2%),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.72) 0 5%, transparent 5.2%),
    radial-gradient(circle at 73% 12%, rgba(255,255,255,0.8) 0 4%, transparent 4.2%),
    radial-gradient(circle at 77% 14%, rgba(255,255,255,0.65) 0 5%, transparent 5.2%);
  opacity: 0.75;
  pointer-events: none;
}

.shell {
  --playfield-gap: clamp(10px, 1.5vw, 16px);
  width: 100vw;
  height: 100dvh;
  padding: var(--playfield-gap);
  display: grid;
  place-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: rgba(23, 52, 59, 0.66);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 0.98;
}

.lede {
  margin-top: 12px;
  font-size: 1.02rem;
  line-height: 1.5;
}

.hud {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.hud-top {
  position: absolute;
  inset: 14px 14px auto 14px;
  z-index: 3;
  pointer-events: none;
}

.hud-compact {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.menu-button {
  -webkit-appearance: none;
  appearance: none;
  width: 52px;
  height: 52px;
  display: grid;
  gap: 5px;
  align-content: center;
  justify-items: center;
  padding: 0;
  border: none;
  outline: none;
  background: rgba(23, 52, 59, 0.74);
  color: var(--white);
  box-shadow: 0 6px 16px rgba(23, 52, 59, 0.16);
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.menu-button span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.menu-button:focus,
.menu-button:active {
  outline: none;
}

.status-hud {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  max-width: min(58vw, 460px);
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(250, 244, 224, 0.22);
  box-shadow: 0 4px 10px rgba(23, 52, 59, 0.08);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

#statusText {
  font-weight: 700;
  line-height: 1.35;
}

.stat {
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(250, 244, 224, 0.18);
  box-shadow: 0 4px 10px rgba(23, 52, 59, 0.06);
  backdrop-filter: blur(4px);
  text-align: center;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(23, 52, 59, 0.62);
}

.stat strong {
  font-size: 1.2rem;
}

.game-card {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  display: grid;
  place-items: center;
}

.game-layout {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

button {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  border: none;
}

button {
  cursor: pointer;
  background: rgba(23, 52, 59, 0.74);
  color: var(--white);
  box-shadow: 0 6px 16px rgba(23, 52, 59, 0.16);
  backdrop-filter: blur(8px);
}

button:hover {
  transform: translateY(-1px);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: min(
    calc(100vw - (var(--playfield-gap) * 2)),
    calc((100dvh - (var(--playfield-gap) * 2)) * 1.5)
  );
  max-height: calc(100dvh - (var(--playfield-gap) * 2));
  aspect-ratio: 960 / 640;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #8fc96e 0%, #6ca756 100%);
  box-shadow:
    0 14px 34px rgba(12, 28, 31, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(12, 28, 31, 0.12);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  max-width: 420px;
  margin: 20px;
  padding: 28px;
  border-radius: 28px;
  background: rgba(253, 246, 226, 0.58);
  box-shadow: 0 8px 22px rgba(12, 28, 31, 0.14);
  backdrop-filter: blur(4px);
  text-align: center;
}

.overlay-card h2 {
  margin-bottom: 12px;
  font-size: 2rem;
}

.overlay-card p {
  line-height: 1.5;
}

.overlay-card button {
  margin-top: 18px;
}

.actions {
  display: flex;
  gap: 10px;
}

.control-actions {
  flex-direction: column;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(14, 33, 37, 0.36);
  backdrop-filter: blur(6px);
}

.menu-overlay.hidden {
  display: none;
}

.menu-card {
  width: min(360px, calc(100vw - 32px));
  padding: 22px;
  border-radius: 28px;
  background: rgba(253, 246, 226, 0.94);
  box-shadow: 0 18px 36px rgba(12, 28, 31, 0.22);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.menu-close-button {
  min-width: 92px;
}

.control-actions button {
  width: 100%;
}

.splash-overlay,
.rotate-prompt {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-right: max(28px, env(safe-area-inset-right, 0px));
  padding-bottom: 24px;
  padding-left: max(28px, env(safe-area-inset-left, 0px));
  background: rgba(14, 33, 37, 0.78);
}

.splash-overlay {
  z-index: 11;
}

.rotate-prompt {
  z-index: 10;
}

.splash-overlay.active,
.rotate-prompt.active {
  display: grid;
}

.startup-card {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 28px;
  background: rgba(253, 246, 226, 0.94);
  box-shadow: 0 18px 42px rgba(12, 28, 31, 0.26);
  text-align: center;
}

.startup-card h2 {
  margin-bottom: 12px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.02;
}

.startup-copy {
  line-height: 1.5;
}

.startup-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.splash-card {
  position: relative;
  width: min(920px, 100%);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(12, 28, 31, 0.26);
}

.splash-image {
  display: block;
  width: 100%;
  height: auto;
}

.splash-start-button {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  min-width: 160px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: 0 10px 30px rgba(12, 28, 31, 0.28);
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.splash-start-button:hover {
  transform: translateX(-50%) translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
}

.ghost-button {
  background: rgba(23, 52, 59, 0.08);
  color: var(--ink);
  box-shadow: none;
}

@media (max-width: 900px) and (max-aspect-ratio: 3/2) {
  .shell {
    --playfield-gap: 10px;
  }

  .game-card {
    padding: 0;
  }

  .game-layout {
    place-items: center;
  }

  .canvas-wrap {
    max-width: min(
      calc(100vw - (var(--playfield-gap) * 2)),
      calc((100dvh - (var(--playfield-gap) * 2)) * 1.5)
    );
    max-height: calc(100dvh - (var(--playfield-gap) * 2));
    border-radius: 12px;
  }

  .hud-top {
    inset: 8px 8px auto 8px;
    gap: 8px;
  }

  .menu-button {
    width: 46px;
    height: 46px;
  }

  .hud-compact {
    gap: 8px;
  }

  .status-hud {
    left: 8px;
    bottom: 8px;
    max-width: min(72vw, 360px);
    padding: 8px 10px;
  }

  .control-actions {
    flex-direction: column;
  }

  .control-actions button {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .stat {
    min-width: 74px;
    padding: 8px 9px;
  }

  button {
    padding: 9px 12px;
  }

  #statusText {
    font-size: 0.9rem;
  }

  .label {
    font-size: 0.62rem;
  }

  .stat strong {
    font-size: 1rem;
  }

  .splash-card {
    width: min(70vw, 672px);
    border-radius: 20px;
  }

  .splash-start-button {
    min-width: 118px;
    padding: 11px 16px;
    bottom: 22%;
    letter-spacing: 0.12em;
  }

  .startup-card {
    padding: 22px;
    border-radius: 22px;
  }

  .startup-actions {
    flex-direction: column;
  }

  .startup-actions button {
    width: 100%;
  }
}

@media (max-width: 640px) and (max-aspect-ratio: 3/2) {
  .menu-card {
    padding: 18px;
    border-radius: 22px;
  }
}
