:root {
  color-scheme: light;
  --ink: #15222d;
  --muted: #637282;
  --line: #cbd8d7;
  --panel: rgba(250, 253, 251, 0.94);
  --accent: #126e68;
  --accent-dark: #0b514d;
  --danger: #b83232;
  --gold: #c4861c;
  --shadow: 0 18px 48px rgba(18, 33, 42, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: #7fc0cb;
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 2.55rem;
  border: 1px solid #b8c8c5;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  font-weight: 850;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 110, 104, 0.14);
}

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

.primary-button {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.arcade-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.hud {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  right: 0.85rem;
  display: grid;
  grid-template-columns: minmax(12rem, 1.1fr) repeat(5, minmax(5rem, 0.42fr));
  gap: 0.55rem;
  align-items: stretch;
  pointer-events: none;
}

.title-block,
.hud-stat,
.tool-row,
.prompt {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.title-block {
  padding: 0.7rem 0.85rem;
}

.title-block p {
  margin: 0 0 0.1rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.title-block h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 2.25rem);
  line-height: 1;
}

.hud-stat {
  padding: 0.62rem 0.7rem;
}

.hud-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.hud-stat strong {
  display: block;
  margin-top: 0.08rem;
  font-size: 1.18rem;
  line-height: 1.1;
}

.tool-row {
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.85rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(7.2rem, 1fr));
  gap: 0.55rem;
  padding: 0.7rem;
}

.tool-row button span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.tool-row button.active {
  border-color: var(--accent);
  background: #eefaf6;
  box-shadow: 0 0 0 3px rgba(18, 110, 104, 0.15);
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 5.9rem;
  max-width: min(42rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  padding: 0.7rem 0.9rem;
  color: #314352;
  font-weight: 800;
  text-align: center;
}

.danger-text {
  color: var(--danger);
}

.tutorial-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 33, 42, 0.72);
}

.tutorial-overlay[hidden] {
  display: none;
}

.tutorial-card {
  display: grid;
  gap: 0.85rem;
  width: min(42rem, calc(100vw - 2rem));
  border: 1px solid #f4c95d;
  border-radius: 8px;
  padding: 1rem;
  background: #fbfdfc;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.tutorial-art {
  overflow: hidden;
  min-height: 12rem;
  border: 1px solid #bed4d2;
  border-radius: 8px;
  background: #86cbd8;
}

.tutorial-art svg {
  display: block;
  width: 100%;
  height: 12rem;
}

.tutorial-copy {
  display: grid;
  gap: 0.35rem;
}

.tutorial-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.tutorial-copy h2,
.tutorial-copy p {
  margin: 0;
}

.tutorial-copy h2 {
  font-size: 1.35rem;
}

.tutorial-copy p {
  color: #334452;
  font-weight: 700;
  line-height: 1.45;
}

.tutorial-progress {
  display: flex;
  gap: 0.4rem;
}

.tutorial-progress span {
  width: 2.1rem;
  height: 0.38rem;
  border-radius: 999px;
  background: #d5e4e1;
}

.tutorial-progress span.active {
  background: var(--accent);
}

.tutorial-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.end-dialog {
  width: min(50rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.end-dialog::backdrop {
  background: rgba(9, 28, 36, 0.52);
}

.end-dialog form {
  display: grid;
  gap: 0.85rem;
}

.end-dialog p {
  margin: 0;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.end-dialog h2 {
  margin: 0;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(7rem, 1fr));
  gap: 0.55rem;
}

.end-stats div {
  padding: 0.65rem;
  border: 1px solid #dce7e4;
  border-radius: 8px;
  background: #f8fcfa;
}

.end-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.end-stats strong {
  display: block;
}

.end-stats div:last-child:nth-child(5) {
  grid-column: 1 / -1;
}

.leaderboard-panel {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 2px solid #173c52;
  border-radius: 8px;
  background: linear-gradient(180deg, #102e3d, #174a62);
  color: #ffffff;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: minmax(8rem, 0.35fr) minmax(8rem, 0.25fr);
  gap: 0.6rem;
  align-items: end;
}

.leaderboard-entry label {
  color: #ffffff;
}

.leaderboard-entry input {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid #f4c95d;
  border-radius: 7px;
  padding: 0.45rem 0.6rem;
  color: #102e3d;
  background: #fffdf2;
  font-weight: 900;
}

.leaderboard-status {
  color: #f4d889;
  font-size: 0.88rem;
  font-weight: 800;
}

.leaderboard-list {
  display: grid;
  gap: 0.32rem;
  margin: 0;
  padding-left: 1.45rem;
}

.leaderboard-list li {
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 850;
}

label {
  display: grid;
  gap: 0.3rem;
  color: #334452;
  font-weight: 750;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #bdccca;
  border-radius: 7px;
  padding: 0.55rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .arcade-shell {
    min-height: 100vh;
  }

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

  .title-block {
    grid-column: 1 / -1;
  }

  .tool-row {
    grid-template-columns: repeat(4, 1fr);
  }

  .leaderboard-entry {
    grid-template-columns: 1fr;
  }

  .prompt {
    bottom: 8.4rem;
  }
}
