* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #11151f;
  --panel: rgba(18, 26, 42, 0.86);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #f0f3ff;
  --accent: #5b82ff;
  --canvas-bg: #1f2636;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 16px;
}

.game-header {
  max-width: 1600px;
  margin: 0 auto 12px auto;
}

.game-header h1 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.game-header p {
  font-size: 0.92rem;
  opacity: 0.9;
}

.game-container {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px minmax(640px, 1fr) 300px;
  gap: 12px;
  align-items: start;
  position: relative;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.panel h3,
.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.toggle-btn {
  border: none;
  border-radius: 9px;
  padding: 6px 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

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

.game-controls .toggle-btn {
  flex: 1 1 80px;
}

.message {
  min-height: 46px;
}

.game-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid var(--accent);
  background: var(--canvas-bg);
  border-radius: 12px;
}

.legend {
  display: none;
}

.legend.visible {
  display: block;
}

.legend p,
.hud p,
.message p,
.menu p,
.highscores p {
  font-size: 0.82rem;
  line-height: 1.4;
  margin-bottom: 6px;
}

.hud p:last-child,
.legend p:last-child,
.message p:last-child,
.menu p:last-child,
.highscores p:last-child {
  margin-bottom: 0;
}

.summary-events {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 6px;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}

.touch-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
}

.touch-btn {
  min-width: 48px;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.touch-shots {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 8px;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 20, 0.85);
  padding: 20px;
  border-radius: 12px;
}

.overlay-card {
  width: min(460px, 100%);
  background: rgba(18, 26, 42, 0.98);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}

.overlay-card h2 {
  margin-bottom: 10px;
}

.overlay-card p {
  margin-bottom: 14px;
  font-size: 0.92rem;
}

.overlay-card input {
  width: 100%;
  max-width: 240px;
  margin: 8px auto 12px auto;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 0.95rem;
  text-align: center;
  padding: 10px 12px;
}

.overlay-card button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.hidden {
  display: none;
}

@media (max-width: 1220px) {
  .game-container {
    grid-template-columns: 220px minmax(500px, 1fr) 250px;
  }
}

@media (max-width: 980px) {
  .game-container {
    grid-template-columns: 1fr;
  }

  .column-left {
    order: 1;
  }

  .column-center {
    order: 2;
  }

  .column-right {
    order: 3;
  }
}
