:root {
  color-scheme: dark;
  --bg: #101217;
  --panel: #1b2028;
  --panel-strong: #252c37;
  --text: #f4f7fb;
  --muted: #a0aabc;
  --line: #323b49;
  --accent: #47d6a8;
  --blue: #5ba7ff;
  --danger: #ff5c7a;
  --warning: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(125deg, rgba(71, 214, 168, 0.12), transparent 34%),
    linear-gradient(245deg, rgba(91, 167, 255, 0.12), transparent 38%),
    var(--bg);
}

button,
kbd {
  font: inherit;
}

button {
  cursor: pointer;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(125deg, rgba(71, 214, 168, 0.18), transparent 38%),
    linear-gradient(245deg, rgba(255, 209, 102, 0.12), transparent 42%),
    rgba(16, 18, 23, 0.96);
}

.start-screen.hidden {
  display: none;
}

.start-panel {
  display: grid;
  gap: 18px;
  width: min(100%, 560px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 40, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

.start-options {
  display: grid;
  gap: 10px;
}

.start-mode {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  background: var(--panel-strong);
}

.start-mode strong {
  font-size: 18px;
}

.start-mode.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(71, 214, 168, 0.32);
}

.difficulty-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(37, 44, 55, 0.76);
}

.difficulty-panel.hidden {
  display: none;
}

.difficulty-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.difficulty-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #151a22;
  font-weight: 900;
}

.difficulty-button.active {
  border-color: var(--accent);
  color: #091411;
  background: var(--accent);
}

.start-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #091411;
  background: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

.app-shell {
  display: grid;
  gap: 18px;
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 16px 28px;
}

.top-bar,
.player-card,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 40, 0.92);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.26);
}

.top-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.eyebrow,
.player-label,
.preview-box span,
.stat span {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
}

h3 {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
}

.mode-label,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
}

.mode-label {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0 14px;
  color: var(--accent);
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 20px;
}

.arena {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 18px;
}

.player-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  min-width: 72px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #151a22;
  font-size: 12px;
  text-align: center;
}

.status-pill.danger {
  border-color: rgba(255, 92, 122, 0.65);
  color: var(--danger);
}

.board-zone {
  position: relative;
  width: min(100%, 300px, calc((100vh - 350px) / 2));
  min-width: 220px;
  aspect-ratio: 1 / 2;
  margin: 0 auto;
}

.board-zone canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090d12;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 18px;
  border-radius: 6px;
  text-align: center;
  background: rgba(9, 13, 18, 0.8);
  backdrop-filter: blur(4px);
  font-size: 28px;
  font-weight: 900;
}

.hidden {
  display: none;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat,
.preview-box,
.instructions,
.attack-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(37, 44, 55, 0.76);
}

.stat {
  min-width: 0;
  padding: 10px;
}

.stat span {
  display: block;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
  line-height: 1;
}

.stat.danger strong {
  color: var(--danger);
}

.preview-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.preview-box {
  padding: 10px;
}

.preview-box canvas {
  display: block;
  width: 100%;
  max-width: 118px;
  aspect-ratio: 1;
  margin: 8px auto 0;
  border-radius: 6px;
  background: #10151d;
}

.info-panel {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 360px);
  gap: 12px;
  padding: 14px;
}

.instructions,
.attack-note {
  padding: 14px;
}

.control-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 14px;
}

.control-columns p,
.attack-note p {
  color: var(--muted);
  line-height: 1.8;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 28px;
  margin-right: 5px;
  padding: 3px 8px;
  border: 1px solid #4a5568;
  border-bottom-width: 3px;
  border-radius: 6px;
  color: var(--text);
  background: #151a22;
  font-weight: 900;
}

@media (max-width: 900px) {
  .top-bar,
  .arena,
  .info-panel,
  .control-columns {
    grid-template-columns: 1fr;
  }

  .board-zone {
    width: min(100%, 300px);
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: 12px;
  }

  .mini-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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