:root {
  --bg-top: #f9fafb;
  --bg-bottom: #eceff3;
  --ui: #111827;
  --accent: #ef4444;
  --good: #22c55e;
  --bad: #dc2626;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  font-family: 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 0.02em;
  background:
    radial-gradient(circle at 0% 0%, #ffffff 0%, transparent 40%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--ui);
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.overlay {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.qr-join {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(320px, 84vw);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(17, 24, 39, 0.25);
  padding: 16px;
  text-align: center;
}

.qr-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: #b91c1c;
}

.qr-image {
  width: 220px;
  max-width: 100%;
  height: auto;
  border: 1px solid #d1d5db;
  background: #fff;
}

.qr-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  text-transform: none;
}

.is-hidden {
  display: none !important;
}

.gameover-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.85);
  display: grid;
  place-items: center;
  padding: 20px;
}

.gameover-card {
  width: min(860px, 100%);
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.22);
  padding: 18px;
}

.gameover-card h2 {
  margin: 0 0 12px;
  font-size: 1.8rem;
  text-transform: uppercase;
  color: #b91c1c;
}

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

.brand-tile {
  border: 1px solid #e5e7eb;
  padding: 12px;
  display: grid;
  gap: 8px;
  justify-items: center;
  background: #fff;
}

.brand-tile.compact {
  align-content: start;
}

.brand-logo {
  width: min(220px, 100%);
  height: auto;
  object-fit: contain;
  background: #fff;
}

.brand-name {
  font-weight: 700;
}

.brand-qr {
  width: 150px;
  height: 150px;
  border: 1px solid #e5e7eb;
}

.brand-link {
  color: #b91c1c;
  font-weight: 700;
  text-decoration: none;
}

.brand-contact,
.next-code-hint {
  font-size: 0.9rem;
  text-align: center;
}

.next-game-join {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.panel {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(17, 24, 39, 0.2);
  border-radius: 0;
  padding: 12px;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.code {
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.status {
  font-size: 0.85rem;
}

.screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  width: min(540px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(17, 24, 39, 0.2);
  border-radius: 0;
  padding: 18px;
}

h1 {
  margin: 0 0 12px;
  font-size: 1.35rem;
}

p {
  margin: 0 0 12px;
  line-height: 1.4;
}

label,
input,
button {
  font-size: 1rem;
}

input {
  width: 100%;
  padding: 10px;
  border-radius: 0;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--ui);
  margin-bottom: 10px;
  text-transform: uppercase;
}

button {
  width: 100%;
  padding: 10px;
  border: 1px solid #ef4444;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
}

button.secondary {
  margin-top: 8px;
  background: #fff;
  border-color: #ef4444;
  color: #b91c1c;
}

.steer-meter {
  margin-top: 14px;
  height: 14px;
  border-radius: 0;
  background: #ffffff;
  overflow: hidden;
  border: 1px solid #d1d5db;
}

.steer-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #fca5a5, #ef4444);
  transform-origin: left center;
}

.kpi {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  font-size: 0.9rem;
}

.touch-pad {
  margin-top: 14px;
  height: 140px;
  border: 1px dashed #ef4444;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  touch-action: none;
  user-select: none;
}

.touch-pad-label {
  font-size: 0.9rem;
  text-align: center;
  color: #7f1d1d;
  padding: 0 12px;
}

@media (max-width: 760px) {
  .brand-grid {
    grid-template-columns: 1fr;
  }
}
