:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #63707d;
  --paper: #fffaf2;
  --paper-2: #f3f7f5;
  --line: #d6dfda;
  --navy: #203447;
  --navy-2: #2b445b;
  --teal: #147c83;
  --teal-2: #0f646b;
  --yellow: #f4bd3d;
  --orange: #ee7145;
  --red: #c3483d;
  --green: #2c9a65;
  --focus: #225dff;
  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;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.82), rgba(236, 245, 242, 0.95)),
    linear-gradient(120deg, #d7f3f1 0%, #f7e6b5 54%, #eaf0f8 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  width: min(1120px, calc(100vw - 28px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(260px, 330px);
  justify-content: center;
  align-items: start;
  gap: 18px;
}

.play-section,
.side-panel {
  border: 1px solid rgba(23, 33, 43, 0.12);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.86);
  box-shadow: 0 18px 55px rgba(32, 52, 71, 0.14);
}

.play-section {
  overflow: hidden;
}

.game-header,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 2px solid rgba(23, 33, 43, 0.2);
  border-radius: 8px;
  background:
    radial-gradient(circle at 69% 36%, var(--ink) 0 3px, transparent 4px),
    radial-gradient(ellipse at 42% 58%, var(--yellow) 0 12px, transparent 13px),
    linear-gradient(135deg, var(--orange), #f7c75d);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.04rem;
  line-height: 1.12;
  letter-spacing: 0;
}

.identity p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 850;
  letter-spacing: 0;
}

.icon-button {
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #ffffff;
  background: var(--navy);
}

.icon-button[aria-pressed="true"] {
  background: var(--red);
}

.stage-wrap {
  position: relative;
  width: min(100%, 560px);
  margin: 0 auto;
  aspect-ratio: 420 / 640;
  border-top: 1px solid rgba(23, 33, 43, 0.12);
  background: #81d8e6;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.score-card {
  position: absolute;
  left: 13px;
  top: 13px;
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(32, 52, 71, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.score-card span {
  display: block;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 52, 71, 0.24);
}

.overlay[hidden] {
  display: none;
}

.modal {
  width: min(100%, 334px);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.94);
  box-shadow: 0 18px 50px rgba(32, 52, 71, 0.24);
  backdrop-filter: blur(14px);
}

.kicker {
  color: var(--teal-2);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal h2,
.panel-header h2 {
  margin-top: 4px;
  font-size: 1.54rem;
  line-height: 1.04;
  letter-spacing: 0;
}

#overlayBody {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

.name-form {
  margin-top: 16px;
}

.name-form label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 7px;
}

.name-row input {
  min-width: 0;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0 14px;
}

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

.primary-button:hover {
  background: var(--teal-2);
}

.secondary-button {
  color: var(--ink);
  border-color: var(--line);
  background: #ffffff;
}

.ghost-button {
  min-height: 34px;
  color: var(--navy);
  border-color: var(--line);
  background: var(--paper-2);
}

.side-panel {
  padding-bottom: 12px;
}

.panel-header {
  padding-bottom: 10px;
}

.leaderboard {
  margin: 0;
  padding: 0 14px;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-top: 1px solid var(--line);
}

.leaderboard li:first-child {
  border-top: 0;
}

.leaderboard .rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: #ffffff;
  background: var(--navy-2);
  font-size: 0.82rem;
  font-weight: 900;
}

.leaderboard strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.75rem;
}

.leaderboard .points {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.empty-row {
  grid-template-columns: 1fr;
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 880px) {
  .app-shell {
    width: min(560px, calc(100vw - 20px));
    grid-template-columns: 1fr;
    padding: 10px 0 16px;
    gap: 12px;
  }
}

@media (max-width: 460px) {
  .game-header,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    width: 100%;
  }

  .icon-button {
    flex: 1 1 0;
  }

  .button-text {
    display: inline;
  }

  .modal {
    padding: 16px;
  }

  .name-row {
    grid-template-columns: 1fr;
  }

  .name-row .primary-button {
    width: 100%;
  }
}
