:root {
  color-scheme: dark;
  --bg: #102a32;
  --panel: #173842;
  --panel-strong: #0d2027;
  --river: #1f8da8;
  --river-light: #70d0de;
  --grass: #5b7948;
  --grass-dark: #2e5437;
  --gold: #f4c95d;
  --rust: #ad5d3b;
  --foam: #eaf8f8;
  --ink: #f4fbfa;
  --muted: #a7c2c0;
  --danger: #f08065;
  --shadow: rgba(4, 15, 18, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(92, 153, 171, 0.18), rgba(16, 42, 50, 0.92) 42%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  min-width: 104px;
  min-height: 42px;
  border: 1px solid rgba(234, 248, 248, 0.2);
  border-radius: 8px;
  background: #f4c95d;
  color: #172127;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 8px 20px var(--shadow);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #ffd97a;
}

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

button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.game-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: calc(100svh - 28px);
  margin: 14px auto;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  gap: 12px;
}

.topbar,
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(234, 248, 248, 0.12);
  border-radius: 8px;
  background: rgba(13, 32, 39, 0.78);
  box-shadow: 0 18px 42px var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  line-height: 1;
}

h2 {
  font-size: 1.6rem;
  line-height: 1.12;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, auto));
  gap: 8px;
}

.hud span {
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid rgba(234, 248, 248, 0.12);
  border-radius: 8px;
  background: rgba(234, 248, 248, 0.08);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.hud b {
  display: block;
  color: var(--ink);
  font-size: 1.05rem;
}

.stage {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid rgba(234, 248, 248, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(105, 171, 189, 0.28), transparent 34%),
    #143a43;
  box-shadow: 0 22px 54px var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(8, 28, 34, 0.35), rgba(8, 28, 34, 0.82)),
    rgba(8, 28, 34, 0.2);
}

.overlay.is-visible {
  display: grid;
}

.overlay .status {
  max-width: 480px;
  color: var(--muted);
  line-height: 1.45;
}

.mark {
  width: 74px;
  height: 74px;
  border: 3px solid rgba(234, 248, 248, 0.85);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 20%, #eaf8f8 0 11px, transparent 12px),
    linear-gradient(145deg, transparent 43%, #f4c95d 44% 53%, transparent 54%),
    linear-gradient(30deg, transparent 36%, #70d0de 37% 58%, transparent 59%),
    #1f8da8;
  box-shadow: 0 18px 28px var(--shadow);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
}

.controls-row span {
  min-width: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(234, 248, 248, 0.22);
  border-radius: 6px;
  background: rgba(234, 248, 248, 0.1);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.controls-row .wide {
  min-width: 58px;
}

.bottombar {
  color: var(--muted);
  font-size: 0.88rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.actions button {
  min-width: 92px;
  background: rgba(234, 248, 248, 0.08);
  color: var(--ink);
}

.actions button:hover:not(:disabled) {
  background: rgba(234, 248, 248, 0.16);
}

noscript {
  display: block;
  margin: 16px auto;
  color: #fff;
  text-align: center;
}

@media (max-width: 720px) {
  .game-shell {
    width: min(100% - 16px, 620px);
    min-height: calc(100svh - 16px);
    margin: 8px auto;
    grid-template-rows: auto minmax(480px, 1fr) auto;
    gap: 8px;
  }

  .topbar,
  .bottombar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
  }

  .hud span {
    min-width: 0;
    padding: 7px 6px;
  }

  .stage,
  canvas {
    min-height: 480px;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 130px;
  }
}

@media (max-width: 430px) {
  .hud {
    grid-template-columns: 1fr;
  }

  .stage,
  canvas {
    min-height: 420px;
  }
}
