:root {
  color-scheme: only light;
  --bg-a: #101721;
  --bg-b: #17362e;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-strong: rgba(255, 255, 255, 0.15);
  --text: #f7fbff;
  --muted: rgba(247, 251, 255, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --cyan: #3ee7ff;
  --green: #86ff70;
  --yellow: #ffe66d;
  --red: #ff5c7a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    linear-gradient(140deg, rgba(62, 231, 255, 0.12), transparent 34%),
    linear-gradient(220deg, rgba(134, 255, 112, 0.12), transparent 38%),
    linear-gradient(155deg, var(--bg-a), var(--bg-b));
}

button {
  font: inherit;
}

.app {
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(12px, 2.4vw, 30px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  overflow-y: auto;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  overscroll-behavior: contain;
  transition: opacity 0.22s ease, transform 0.26s ease;
}

.screen--active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.hero,
.result-card,
.modal-card {
  width: min(780px, 100%);
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.06));
  box-shadow: 0 28px 62px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.language-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.language-switch__btn {
  min-width: 40px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
}

.language-switch__btn--active {
  color: #06130f;
  background: var(--green);
}

h1,
h2 {
  margin: 0;
  line-height: 0.96;
}

h1 {
  font-size: clamp(44px, 10vw, 86px);
}

h2 {
  font-size: clamp(38px, 8vw, 68px);
}

.subtitle {
  max-width: 620px;
  margin: 16px auto 0;
  color: var(--muted);
  font-size: clamp(16px, 2.2vw, 21px);
  line-height: 1.45;
}

.setup-grid {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.setup-group {
  display: grid;
  gap: 8px;
}

.setup-group > span,
.hud span,
.status-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.segmented--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented__btn,
.btn,
.icon-btn,
.touch-controls button {
  border: 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.segmented__btn {
  min-height: 42px;
  padding: 9px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  font-weight: 800;
}

.segmented__btn--active {
  color: #06130f;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

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

.btn {
  min-width: 140px;
  padding: 13px 22px;
  border-radius: 999px;
  font-weight: 800;
}

.btn--primary {
  color: #06130f;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 14px 28px rgba(134, 255, 112, 0.22);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.14);
}

.btn:active,
.icon-btn:active,
.touch-controls button:active,
.segmented__btn:active {
  transform: translateY(2px) scale(0.98);
}

.rules {
  width: min(780px, 100%);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  display: grid;
  gap: 8px;
  padding: 0 18px;
  color: var(--muted);
  text-align: center;
  transition: max-height 0.24s ease, opacity 0.24s ease, padding 0.24s ease;
}

.rules--open {
  max-height: 190px;
  opacity: 1;
  padding: 14px 18px;
}

.hud {
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 52px;
  gap: 8px;
  align-items: center;
}

.hud > div,
.icon-btn,
.status-panel > div {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  place-items: center;
}

.hud strong {
  font-size: 21px;
}

.icon-btn {
  width: 52px;
  font-weight: 900;
}

.game-shell {
  width: min(760px, 100%);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: stretch;
}

#game-canvas {
  width: 100%;
  max-height: min(66vh, 620px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #07130f;
  box-shadow:
    0 0 0 1px rgba(134, 255, 112, 0.12),
    0 24px 64px rgba(0, 0, 0, 0.34);
  touch-action: none;
}

.status-panel {
  display: grid;
  gap: 12px;
}

.status-panel > div {
  padding: 10px;
  align-content: center;
  gap: 8px;
}

.status-panel strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.touch-controls {
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.touch-controls button {
  min-height: 48px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  font-size: 22px;
  font-weight: 900;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 10, 18, 0.64);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal--visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  max-width: 460px;
  transform: translateY(14px) scale(0.96);
  transition: transform 0.22s ease;
}

.modal--visible .modal-card {
  transform: translateY(0) scale(1);
}

@media (max-width: 720px) {
  .screen {
    padding: 10px;
    justify-content: flex-start;
    gap: 8px;
  }

  .screen > :first-child {
    margin-top: auto;
  }

  .screen > :last-child {
    margin-bottom: auto;
  }

  .hero,
  .result-card,
  .modal-card {
    padding: 16px;
  }

  .hero-top {
    align-items: flex-start;
    margin-bottom: 8px;
  }

  h1 {
    font-size: clamp(38px, 12vw, 50px);
  }

  h2 {
    font-size: clamp(34px, 10vw, 48px);
  }

  .subtitle {
    margin-top: 10px;
    font-size: 16px;
    line-height: 1.35;
  }

  .setup-grid {
    margin-top: 14px;
    gap: 8px;
  }

  .setup-group {
    gap: 5px;
  }

  .segmented__btn {
    min-height: 40px;
    padding: 7px 5px;
    font-size: clamp(13px, 3.8vw, 16px);
  }

  .actions {
    margin-top: 14px;
  }

  .btn {
    min-width: 0;
    padding: 12px 18px;
  }

  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 46px;
    gap: 6px;
  }

  .hud > div,
  .icon-btn {
    min-height: 44px;
  }

  .hud span,
  .status-panel span {
    font-size: 10px;
  }

  .hud strong {
    font-size: 16px;
  }

  .icon-btn {
    width: 46px;
  }

  .game-shell {
    grid-template-columns: 1fr;
    gap: 8px;
    justify-items: center;
  }

  #game-canvas {
    width: min(100%, 58vh, 480px);
    width: min(100%, 58dvh, 480px);
    justify-self: center;
  }

  .status-panel {
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .status-panel > div {
    min-height: 58px;
    padding: 7px;
    gap: 5px;
  }

  .touch-controls {
    gap: 6px;
  }

  .touch-controls button {
    min-height: 44px;
    font-size: 20px;
  }
}

@media (max-width: 520px) {
  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .touch-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 380px), (max-height: 700px) {
  .screen {
    padding: 8px;
  }

  .hero,
  .result-card,
  .modal-card {
    padding: 14px;
  }

  .hero-top {
    margin-bottom: 6px;
  }

  .eyebrow {
    font-size: 12px;
  }

  .language-switch {
    padding: 3px;
  }

  .language-switch__btn {
    min-width: 36px;
    height: 28px;
  }

  h1 {
    font-size: clamp(34px, 11vw, 42px);
  }

  .subtitle {
    margin-top: 8px;
    font-size: 14px;
  }

  .setup-grid {
    margin-top: 10px;
    gap: 7px;
  }

  .setup-group > span {
    font-size: 10px;
  }

  .segmented {
    gap: 5px;
  }

  .segmented__btn {
    min-height: 36px;
    padding: 6px 4px;
    font-size: 14px;
  }

  .actions {
    margin-top: 12px;
    gap: 8px;
  }

  .btn {
    padding: 11px 15px;
  }

  .hud > div,
  .icon-btn {
    min-height: 40px;
  }

  .icon-btn {
    width: 42px;
  }

  #game-canvas {
    width: min(100%, 48vh, 360px);
    width: min(100%, 48dvh, 360px);
  }

  .status-panel > div {
    min-height: 52px;
  }

  .status-panel strong {
    font-size: 13px;
  }

  .touch-controls button {
    min-height: 40px;
  }
}

@media (max-width: 340px) {
  .segmented--three {
    grid-template-columns: 1fr;
  }
}
