:root {
  --bg-primary: #1c1e21;
  --bg-secondary: #25282c;
  --bg-tertiary: #2d3035;
  --bg-card: #2a2d31;
  --text-primary: #ffffff;
  --text-secondary: #e4e6eb;
  --text-muted: #b0b3b8;
  --accent-primary: #00d4ff;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --danger: #ff4466;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Pad colors: idle ~40% brightness, lit full + glow */
  --pad-top: #2a8f3a;        /* green idle */
  --pad-top-lit: #4dff6a;
  --pad-right: #9e3a2a;      /* red idle */
  --pad-right-lit: #ff5a40;
  --pad-bottom: #2a5f9e;     /* blue idle */
  --pad-bottom-lit: #4da6ff;
  --pad-left: #9e8a2a;       /* amber idle */
  --pad-left-lit: #ffd24d;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 28px;
  font-weight: 700;
  flex: 1;
}
.header-meta {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-primary);
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Focus States (critical for D-pad) --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Menu --- */
.menu-content {
  align-items: center;
  justify-content: center;
  gap: 32px;
}
.menu-tagline {
  font-size: 18px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 420px;
  line-height: 1.4;
}
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 280px;
}

/* --- Nav buttons --- */
.nav-item {
  padding: 16px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary {
  background: var(--accent-primary);
  color: #1c1e21;
}
.nav-item.primary:focus { background: #33ddff; }

/* --- Game content --- */
.game-content {
  align-items: center;
  justify-content: flex-start;
  padding-top: 8px;
}
.status-line {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-height: 28px;
}
.status-line.watch { color: var(--accent-primary); }
.status-line.your-turn { color: #4dff6a; }
.status-line.good { color: #4dff6a; }

/* --- Diamond board --- */
.board {
  position: relative;
  width: 420px;
  height: 420px;
}
.pad {
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  transition: background-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
  /* diamond: rotate the square board's children into a rhombus arrangement */
}
/* Position the four pads with a small gap toward center */
.pad-top    { top: 0;    left: 115px; background: var(--pad-top); }
.pad-right  { top: 115px; right: 0;   background: var(--pad-right); }
.pad-bottom { bottom: 0; left: 115px; background: var(--pad-bottom); }
.pad-left   { top: 115px; left: 0;    background: var(--pad-left); }

/* Lit state: full brightness + glow */
.pad.lit { transform: scale(1.04); }
.pad-top.lit    { background: var(--pad-top-lit);    box-shadow: 0 0 36px 6px rgba(77, 255, 106, 0.6); }
.pad-right.lit  { background: var(--pad-right-lit);  box-shadow: 0 0 36px 6px rgba(255, 90, 64, 0.6); }
.pad-bottom.lit { background: var(--pad-bottom-lit); box-shadow: 0 0 36px 6px rgba(77, 166, 255, 0.6); }
.pad-left.lit   { background: var(--pad-left-lit);   box-shadow: 0 0 36px 6px rgba(255, 210, 77, 0.6); }

/* Pad focus ring (visible during player's turn) */
.pad.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* Center hub */
.board-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

/* --- Overlays --- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(28, 30, 33, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px;
}
.overlay-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.overlay-btn { width: 240px; }

.how-content { align-items: flex-start; }
.how-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.how-list li {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.3;
  padding-left: 22px;
  position: relative;
}
.how-list li::before {
  content: "\25C6";
  position: absolute;
  left: 0;
  color: var(--accent-primary);
  font-size: 12px;
  top: 3px;
}
.how-content .overlay-btn { align-self: center; }

/* --- Game Over --- */
.game-over-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 4px;
}
.game-over-score {
  font-size: 72px;
  font-weight: 800;
  color: #4dff6a;
  line-height: 1;
}
.game-over-label {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.game-over-best {
  font-size: 15px;
  color: var(--accent-primary);
  margin-bottom: 16px;
  min-height: 18px;
}

/* --- Utility --- */
.hidden { display: none !important; }
