:root {
  --bg: #08111f;
  --bg-2: #0d1728;
  --panel: rgba(12, 20, 35, 0.88);
  --panel-strong: rgba(10, 17, 28, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --muted: #b7c3d4;
  --muted-2: #8ea0b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: rgba(255, 255, 255, 0.08);
  --secondary-hover: rgba(255, 255, 255, 0.14);
  --success: #22c55e;
  --danger: #ef4444;
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.32);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.18), transparent 28%),
    linear-gradient(180deg, #07101d 0%, #0a1424 45%, #08101d 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

.page-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}

.site-header {
  margin-bottom: 24px;
}

.brand-block h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #c7d6ea;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subtitle {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.game-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.panel-label {
  margin-bottom: 10px;
  color: #8fb5ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.panel-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.control-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 13px;
}

.keycaps {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.tips-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.game-panel {
  min-width: 0;
}

.game-ui {
  margin-bottom: 14px;
}

.hud-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.hud-group {
  min-width: 0;
}

.hud-group-center {
  text-align: center;
}

.hud-group-right {
  text-align: right;
}

.hud-label {
  margin-bottom: 4px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-value {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.hud-timer {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: #fff;
}

.canvas-wrap {
  position: relative;
  border-radius: 22px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: #111827;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 50px rgba(0, 0, 0, 0.45);
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 8, 16, 0.72);
  backdrop-filter: blur(10px);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  z-index: 100;
}

.fullscreen-overlay.visible {
  visibility: visible;
  opacity: 1;
}

.overlay-card {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
}

.overlay-inline {
  margin-bottom: 10px;
  padding: 22px 22px 20px;
}

.overlay-inline h2,
.overlay-centered h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.overlay-inline p,
.overlay-centered p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.overlay-centered {
  width: min(520px, 100%);
  padding: 28px 28px 24px;
  text-align: center;
}

.overlay-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.18);
  color: #b9d2ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.end-card h2 {
  margin-bottom: 8px;
}

#end-message {
  font-size: 15px;
}

.end-actions,
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.hidden {
  display: none !important;
}

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

  .info-panel {
    order: 2;
  }

  .game-panel {
    order: 1;
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 20px 12px 28px;
  }

  .hud-bar {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .hud-group-center,
  .hud-group-right {
    text-align: left;
  }

  .overlay-inline,
  .overlay-centered {
    padding: 20px 18px;
    border-radius: 18px;
  }

  .control-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .keycaps {
    min-width: 0;
  }
}