:root {
  --bg: #0f0e12;
  --panel: #1a1822;
  --text: #e8e4ef;
  --muted: #8a8494;
  --accent: #ff6b35;
  --accent2: #00d4aa;
  --p1: #4dabf7;
  --p2: #ff6b9d;
  --bar-bg: #2a2635;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, #252030 0%, var(--bg) 55%);
  color: var(--text);
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--p1), var(--accent), var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.toggle input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.btn {
  padding: 0.45rem 1rem;
  border: 1px solid #3d3848;
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
  color: #fff;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bar-wrap.p2 {
  align-items: flex-end;
}

.bar-wrap.p2 .bar-outer {
  flex-direction: row-reverse;
}

.name {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bar-wrap.p1 .name {
  color: var(--p1);
}

.bar-wrap.p2 .name {
  color: var(--p2);
}

.bar-outer {
  width: 100%;
  max-width: 340px;
  height: 18px;
  background: var(--bar-bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #3d3848;
  display: flex;
}

.bar-inner {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transition: transform 0.12s ease-out;
}

.bar-wrap.p1 .bar-inner {
  background: linear-gradient(90deg, #1864ab, var(--p1));
}

.bar-wrap.p2 .bar-inner {
  background: linear-gradient(90deg, #c2255c, var(--p2));
  transform-origin: right center;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  min-width: 2.5rem;
  text-align: center;
}

.status {
  text-align: center;
  min-height: 1.5rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--muted);
}

.canvas-wrap {
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #3d3848;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  background: #000;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
  cursor: crosshair;
}

#game:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.help {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid #2f2a3a;
}

.help h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.help h3 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.help ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.6;
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: #2a2635;
  border: 1px solid #4a4458;
  border-radius: 4px;
}

.hint {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}
