:root {
  color-scheme: dark;
  --bg: #101413;
  --panel: rgba(18, 24, 22, 0.92);
  --line: rgba(206, 222, 209, 0.18);
  --text: #eef7f0;
  --muted: #adbbb0;
  --green: #7ad66d;
  --red: #e45b5b;
  --amber: #f1b75b;
  --cyan: #68c7d8;
  --class: #68c7d8;
  --class-accent: #9eefff;
  --class-dark: #1e5665;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  min-height: 480px;
  background: #0f1412;
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #141a17;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 8, 7, 0.48);
  backdrop-filter: blur(2px);
  z-index: 10;
}

.hidden {
  display: none;
}

.panel {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  padding: 28px;
}

.start-panel {
  display: grid;
  gap: 18px;
}

.compact-panel {
  display: grid;
  gap: 18px;
  width: min(520px, calc(100vw - 32px));
}

.kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(36px, 7vw, 72px);
}

h2 {
  font-size: clamp(30px, 5vw, 48px);
}

.subtitle,
.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.briefing {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.briefing span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.class-card {
  display: grid;
  gap: 8px;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.class-card:hover,
.class-card.selected {
  border-color: color-mix(in srgb, var(--class) 74%, white 12%);
  background: color-mix(in srgb, var(--class) 16%, transparent);
  color: var(--text);
}

.class-name {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.menu-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 18px;
}

.primary-button {
  border: 0;
  background: var(--class);
  color: #0b120d;
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover {
  filter: brightness(1.08);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.stats dt {
  color: var(--muted);
  font-size: 13px;
}

.stats dd {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

.touch-zone {
  position: absolute;
  display: none;
  touch-action: none;
  user-select: none;
  z-index: 6;
}

.touch-move {
  left: 22px;
  bottom: 24px;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(238, 247, 240, 0.22);
  border-radius: 50%;
  background: rgba(238, 247, 240, 0.08);
}

.touch-move span {
  position: absolute;
  left: 36px;
  top: 36px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(238, 247, 240, 0.34);
}

.touch-fire {
  right: 26px;
  bottom: 34px;
  width: 86px;
  height: 86px;
  border: 1px solid rgba(228, 91, 91, 0.8);
  border-radius: 50%;
  background: color-mix(in srgb, var(--class) 35%, transparent);
  color: #fff;
  font-size: 42px;
}

@media (max-width: 760px), (pointer: coarse) {
  .touch-zone {
    display: block;
  }

  .game-shell {
    min-height: 100svh;
  }

  .overlay {
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .panel {
    width: min(560px, calc(100vw - 20px));
    padding: 18px;
  }

  .class-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .class-card {
    min-height: 84px;
    padding: 13px;
  }

  .menu-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: clamp(34px, 12vw, 52px);
  }

  .touch-move {
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
  }

  .touch-fire {
    right: max(22px, env(safe-area-inset-right));
    bottom: max(26px, env(safe-area-inset-bottom));
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .panel {
    max-height: calc(100vh - 18px);
    padding: 14px;
  }

  .start-panel {
    gap: 10px;
  }

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

  .class-card {
    min-height: 78px;
    padding: 10px;
  }

  .subtitle,
  .hint {
    font-size: 13px;
  }
}
