:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: rgba(248, 251, 255, 0.76);
  --glass: rgba(4, 26, 40, 0.72);
  --glass-strong: rgba(4, 26, 40, 0.9);
  --line: rgba(255, 255, 255, 0.26);
  --coral: #ff7d66;
  --gold: #ffd166;
  --mint: #79ffd3;
  --shadow: rgba(0, 20, 28, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background-color: #063447;
  background-image: url("./assets/ocean-background.svg");
  background-position: center;
  background-size: cover;
  color: var(--ink);
}

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

.game-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 22px);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 209, 102, 0.28), transparent 22rem),
    linear-gradient(180deg, rgba(2, 19, 34, 0.14), rgba(2, 14, 22, 0.58));
}

.game-stage {
  position: relative;
  width: min(100%, 1280px);
  aspect-ratio: 16 / 9;
  max-height: calc(100svh - 20px);
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #096172;
  box-shadow: 0 22px 70px var(--shadow);
  touch-action: none;
}

.hud,
.top-actions,
.control-pad,
.panel {
  position: absolute;
  z-index: 2;
}

.hud {
  top: clamp(10px, 2vw, 18px);
  left: clamp(10px, 2vw, 18px);
  right: clamp(10px, 2vw, 18px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  pointer-events: none;
}

.stat {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 25, 38, 0.62);
  backdrop-filter: blur(10px);
}

.stat span,
.stat strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat span {
  color: var(--muted);
  font-size: clamp(0.64rem, 1.5vw, 0.78rem);
  text-transform: uppercase;
  letter-spacing: 0;
}

.stat strong {
  margin-top: 2px;
  font-size: clamp(1rem, 2.5vw, 1.55rem);
  line-height: 1;
}

.top-actions {
  top: clamp(78px, 10vw, 94px);
  right: clamp(10px, 2vw, 18px);
  display: flex;
  gap: 8px;
}

.ghost-button,
.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(3, 25, 38, 0.64);
  backdrop-filter: blur(10px);
}

.ghost-button:hover,
.primary-button:hover,
.secondary-button:hover,
.pad-button:hover {
  transform: translateY(-1px);
}

.ghost-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.pad-button:focus-visible {
  outline: 3px solid rgba(121, 255, 211, 0.88);
  outline-offset: 2px;
}

.panel {
  left: 50%;
  top: 50%;
  width: min(92%, 460px);
  transform: translate(-50%, -50%);
  display: none;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(4, 36, 52, 0.9), rgba(2, 22, 34, 0.86));
  box-shadow: 0 18px 60px rgba(0, 15, 24, 0.46);
  backdrop-filter: blur(16px);
}

.panel.is-visible {
  display: block;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel h1,
.panel h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.panel-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.primary-button,
.secondary-button {
  padding: 0 18px;
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(135deg, var(--coral), #ffb45d);
  color: #09222d;
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
}

.credits-list {
  display: grid;
  gap: 8px;
  margin: 20px 0 22px;
}

.credits-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.credits-list dt,
.credits-list dd {
  margin: 0;
}

.credits-list dt {
  color: var(--muted);
}

.credits-list dd {
  font-size: 1.2rem;
  font-weight: 900;
}

.credits-list .total-row {
  border-bottom: 0;
  color: var(--gold);
}

.control-pad {
  right: clamp(12px, 3vw, 24px);
  bottom: clamp(12px, 3vw, 24px);
  width: 132px;
  height: 132px;
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 0;
}

.pad-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(3, 25, 38, 0.62);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.pad-button span {
  display: block;
  width: 0;
  height: 0;
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}

.pad-left {
  grid-column: 1;
  grid-row: 2;
}

.pad-right {
  grid-column: 3;
  grid-row: 2;
}

.pad-down {
  grid-column: 2;
  grid-row: 3;
}

.pad-up span {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 13px solid var(--ink);
}

.pad-down span {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 13px solid var(--ink);
}

.pad-left span {
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 13px solid var(--ink);
}

.pad-right span {
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid var(--ink);
}

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

  .game-stage {
    width: 100vw;
    max-height: 100svh;
    aspect-ratio: auto;
    height: 100svh;
  }

  #gameCanvas {
    border: 0;
    border-radius: 0;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    right: auto;
    width: min(62vw, 330px);
  }

  .top-actions {
    top: auto;
    bottom: clamp(12px, 3vw, 24px);
    left: clamp(12px, 3vw, 24px);
    right: auto;
    flex-direction: column;
  }

  .ghost-button {
    width: 112px;
  }
}

@media (max-width: 460px) {
  .hud {
    width: min(70vw, 292px);
  }

  .stat {
    padding: 7px 8px;
  }

  .panel {
    width: calc(100% - 28px);
  }

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

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
