:root {
  --bg-primary: #000000; /* black = transparent on the additive display */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #707080;
  --accent-primary: #00d4ff;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.45);
  --ok: #00ff88;
  --danger: #ff4466;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
button { color: inherit; font-family: inherit; }
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; }

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

.header { display: flex; align-items: center; padding: 12px 20px; background: var(--bg-secondary); gap: 12px; flex-shrink: 0; }
.header h1 { font-size: 22px; font-weight: 600; flex: 1; }
.header-meta { font-size: 14px; color: var(--text-secondary); }
.back-btn { background: transparent; color: var(--text-primary); font-size: 22px; padding: 6px 10px; border-radius: var(--radius-sm); border: 2px solid transparent; }
.status-pill { padding: 4px 12px; border-radius: 20px; font-weight: 700; background: rgba(255,68,102,.18); color: var(--danger); }
.status-pill.ok { background: rgba(0,255,136,.18); color: var(--ok); }

.content { flex: 1; min-height: 0; padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.content.centered { align-items: center; justify-content: center; text-align: center; gap: 18px; }

.focusable { transition: border-color .1s ease, box-shadow .1s ease, background .1s ease, transform .05s ease; border: 2px solid transparent; cursor: pointer; }
.focusable:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 22px var(--focus-glow); }
.focusable:active, .focusable.pressed { transform: scale(0.94); background: rgba(0,212,255,.25); }

/* ===== Now playing ===== */
.now-playing { background: var(--bg-card); border-radius: var(--radius-md); padding: 10px 16px; margin: 10px 16px 0; flex-shrink: 0; }
.np-app { font-size: 13px; color: var(--accent-primary); font-weight: 700; }
.np-title { font-size: 16px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== D-pad (+ shape) ===== */
.dpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 8px; width: 300px; height: 300px; margin: 14px auto 6px; }
.dbtn { background: var(--bg-tertiary); border-radius: var(--radius-md); font-size: 30px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; justify-content: center; }
.dbtn.up { grid-area: 1 / 2; } .dbtn.left { grid-area: 2 / 1; } .dbtn.ok { grid-area: 2 / 2; }
.dbtn.right { grid-area: 2 / 3; } .dbtn.down { grid-area: 3 / 2; }
.dbtn.ok { background: var(--bg-card); border-radius: 50%; font-size: 26px; font-weight: 800; color: var(--accent-primary); }

/* ===== Button rows ===== */
.btn-row { display: flex; gap: 8px; padding: 0 16px; flex-shrink: 0; }
.rbtn { flex: 1; background: var(--bg-tertiary); border-radius: var(--radius-md); padding: 14px 8px; font-size: 15px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 50px; }
.rbtn.wide { flex: 2; }

/* ===== Pairing ===== */
.big-btn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; max-width: 420px; padding: 18px 22px; background: var(--bg-card); border-radius: var(--radius-lg); color: var(--text-primary); font-size: 19px; font-weight: 600; }
.big-btn.primary { background: rgba(0,212,255,.16); color: var(--accent-primary); }
.big-btn.danger { background: rgba(255,68,102,.16); color: var(--danger); }
.big-status { font-size: 30px; font-weight: 800; color: var(--ok); }
.sub-status { font-size: 16px; color: var(--text-secondary); max-width: 460px; line-height: 1.4; }
.sub-status.err { color: var(--danger); min-height: 20px; }
.pin { display: flex; gap: 14px; justify-content: center; align-items: center; margin: 6px 0; }
.digit { width: 64px; height: 84px; background: var(--bg-card); border-radius: var(--radius-md); font-size: 48px; font-weight: 800; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; color: var(--text-primary); }
.pin-ok { height: 84px; padding: 0 24px; border-radius: var(--radius-md); font-size: 38px; font-weight: 800; background: rgba(0, 212, 255, 0.16); color: var(--accent-primary); display: flex; align-items: center; justify-content: center; }

/* ===== Toast ===== */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-120px); background: var(--bg-card); color: var(--text-primary); padding: 12px 24px; border-radius: 24px; font-size: 15px; border: 1px solid var(--accent-primary); transition: transform .3s ease; z-index: 100; pointer-events: none; max-width: 80%; text-align: center; }
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
