:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #11131b;
  color: #f4f5f8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -20%, #282e40 0, transparent 60%),
    #11131b;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  background: #b9e57a;
  color: #171a16;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover:not(:disabled) {
  background: #d0f49a;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
  opacity: 0.72;
}

input {
  min-width: 0;
  border: 1px solid #454b5d;
  border-radius: 8px;
  padding: 0.75rem;
  background: #11131b;
  color: #fff;
}

select {
  width: min(100%, 24rem);
  border: 1px solid #454b5d;
  border-radius: 8px;
  padding: 0.75rem;
  background: #11131b;
  color: #fff;
}

.shell {
  width: min(100% - 2rem, 900px);
  margin: 0 auto;
  padding: 3.5rem 0 2rem;
}

.masthead {
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: #b9e57a;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.4rem;
  font-size: clamp(2.8rem, 9vw, 5rem);
  letter-spacing: -0.07em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.intro,
.notice,
.hint,
footer {
  color: #a8adbb;
}

.intro {
  margin-bottom: 0;
}

.panel {
  padding: clamp(1rem, 4vw, 1.5rem);
  border: 1px solid #333848;
  border-radius: 16px;
  background: #1b1e29;
  box-shadow: 0 24px 80px #0004;
}

.panel-heading,
.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.status {
  color: #c6d4b1;
  font-size: 0.9rem;
}

.status.error {
  color: #ff9c9c;
}

.lobby-actions,
.join-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button-secondary,
.button-tertiary {
  border: 1px solid #586044;
  background: #2a3028;
  color: #e4f1d0;
}

.button-secondary:hover:not(:disabled),
.button-tertiary:hover:not(:disabled) {
  background: #39432f;
}

.button-tertiary {
  border-color: #454b5d;
  background: #252936;
  color: #d1d5df;
}

.join-form {
  margin-top: 1.5rem;
}

.join-form label,
.ruleset-choice label {
  display: block;
  margin-bottom: 0.5rem;
  color: #e5e7ed;
  font-size: 0.9rem;
  font-weight: 650;
}

.ruleset-choice {
  margin-top: 1.25rem;
}

.join-row input {
  flex: 1 1 12rem;
}

#room-code {
  max-width: 15rem;
  font-family: ui-monospace, monospace;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
}

.powerup-guide {
  border-top: 1px solid #333848;
  padding-top: 0.75rem;
  color: #c6cad4;
  line-height: 1.5;
}

.powerup-guide summary {
  color: #e5e7ed;
  cursor: pointer;
  font-weight: 700;
}

.powerup-guide p {
  margin: 0.75rem 0 0;
}

.invite-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #454b5d;
  border-radius: 10px;
  background: #171a24;
}

.match-invite {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 1.25fr);
  align-items: center;
  gap: 0.25rem 1rem;
  margin: 0 0 1rem;
  border-color: #697b50;
  background: #20271e;
}

.match-invite .eyebrow {
  margin-bottom: 0.35rem;
}

.match-invite .invite-code {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.2rem);
}

.match-invite-actions {
  display: flex;
  gap: 0.65rem;
}

.match-invite-actions input {
  flex: 1;
}

.match-invite .hint {
  grid-column: 1 / -1;
}

.invite-code {
  margin-bottom: 0.75rem;
  color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

#invite-link {
  font-size: 0.82rem;
}

.notice {
  margin: 1.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.game-panel {
  position: relative;
}

.game-heading {
  margin-bottom: 1rem;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #353a4a;
  border-radius: 10px;
  background: #171a25;
  image-rendering: pixelated;
}

.match-result {
  position: absolute;
  inset: 25% 10% auto;
  padding: 1.25rem;
  border: 1px solid #697b50;
  border-radius: 12px;
  background: #171a24f2;
  text-align: center;
}

.match-result p {
  margin-bottom: 1rem;
  font-size: 1.4rem;
  font-weight: 800;
}

.control-guide {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 1rem;
}

.control-guide p {
  margin: 0;
  color: #c3c7d1;
  font-size: 0.8rem;
}

kbd {
  display: inline-block;
  min-width: 1.35rem;
  margin: 0 0.08rem;
  border: 1px solid #51586c;
  border-radius: 4px;
  padding: 0.12rem 0.24rem;
  color: #fff;
  font: 700 0.72rem ui-monospace, monospace;
  text-align: center;
}

.player-label {
  margin-right: 0.3rem;
  font-weight: 900;
}

.blue {
  color: #78c8ff;
}

.orange {
  color: #ffad73;
}

.touch-controls {
  display: none;
  gap: 0.75rem;
  padding-top: 1rem;
}

.touch-player {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.touch-player button {
  min-width: 2.8rem;
  min-height: 2.8rem;
  padding: 0.5rem;
  border: 1px solid #454b5d;
  background: #252936;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touch-player button:active {
  background: #39432f;
}

footer {
  padding: 1.5rem 0 0;
  font-size: 0.82rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
    flex-direction: column;
  }
}

@media (max-width: 540px) {
  .shell {
    padding-top: 2.5rem;
  }

  .panel-heading,
  .game-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-heading {
    flex-direction: row;
    align-items: center;
  }

  .match-invite {
    grid-template-columns: 1fr;
  }

  .match-invite .hint {
    grid-column: auto;
  }

  .match-invite-actions {
    flex-direction: column;
  }

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