:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- HOME ---------- */
.hdr {
  padding: 36px 32px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.hdr h1 {
  font-size: 38px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(120deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--text-secondary); font-size: 18px; }
.sub b { color: var(--accent); font-weight: 700; }

.menu {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 8px 32px 32px;
}
.menu-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: left; min-height: 88px; justify-content: center;
}
.mi-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.mi-desc { font-size: 15px; color: var(--text-secondary); }

/* ---------- BAR (sub-screen headers) ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
  background: var(--bg-primary);
  border-bottom: 1px solid #26263a;
}
.bar-title { font-size: 26px; font-weight: 800; }
.bar-config {
  font-size: 20px; font-weight: 700; color: var(--accent);
  background: var(--bg-tertiary); padding: 6px 16px; border-radius: 999px;
}

/* ---------- DICE ---------- */
.stage {
  flex: 1;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 16px; padding: 16px 24px;
}
.die {
  width: 124px; height: 124px;
  background: linear-gradient(155deg, #24243a, #15151f);
  border-radius: 22px;
  border: 1px solid #34344e;
  box-shadow: 0 8px 18px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.logo.die { width: 92px; height: 92px; box-shadow: 0 6px 16px rgba(0,212,255,0.18); }
.pipgrid {
  width: 100%; height: 100%; padding: 20px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 6px;
}
.logo .pipgrid { padding: 14px; }
.pip { align-self: center; justify-self: center; width: 20px; height: 20px; border-radius: 50%; background: transparent; }
.logo .pip { width: 15px; height: 15px; }
.pip.on {
  background: var(--text-primary);
  box-shadow: 0 0 8px rgba(255,255,255,0.55);
}
.die.num { flex-direction: column; gap: 2px; }
.dnum { font-size: 58px; font-weight: 800; color: var(--accent); line-height: 1; }
.dlabel { font-size: 14px; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; }

.stage.rolling .die { animation: tumble 0.16s ease-in-out infinite; }
@keyframes tumble {
  0%   { transform: translateY(0) rotate(0deg); }
  25%  { transform: translateY(-7px) rotate(-9deg); }
  75%  { transform: translateY(-3px) rotate(9deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* ---------- RESULT ---------- */
.result {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0 2px;
}
.result-label { font-size: 13px; letter-spacing: 3px; color: var(--text-muted); font-weight: 700; }
.result-total {
  font-size: 46px; font-weight: 800;
  background: linear-gradient(120deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.status { text-align: center; color: var(--text-secondary); font-size: 16px; padding: 2px 0 6px; min-height: 22px; }

/* ---------- ACTIONS / BUTTONS ---------- */
.actions { display: flex; gap: 14px; padding: 16px 32px 28px; }
.btn {
  flex: 1; min-height: 88px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-secondary));
  color: #04121a;
}

/* ---------- SETTINGS ---------- */
.setting { padding: 18px 32px 6px; }
.setting-label { font-size: 17px; color: var(--text-secondary); margin-bottom: 12px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; }
.chip {
  min-width: 72px; min-height: 64px; padding: 0 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.chip.selected {
  background: var(--bg-tertiary);
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
  box-shadow: inset 0 0 0 1px var(--accent-secondary);
}
.chip.selected.focusable:focus { border-color: var(--focus-ring); }

/* ---------- HISTORY ---------- */
.hist-list {
  flex: 1; overflow-y: auto; padding: 16px 32px;
  display: flex; flex-direction: column; gap: 10px;
}
.hist-row {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.hist-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hist-label { font-size: 18px; font-weight: 700; color: var(--accent); }
.hist-vals { font-size: 15px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-total { font-size: 30px; font-weight: 800; color: var(--text-primary); flex-shrink: 0; }
.hist-time { font-size: 13px; color: var(--text-muted); }
.hist-empty { color: var(--text-muted); text-align: center; padding: 60px 20px; font-size: 18px; }

/* ---------- HELP ---------- */
.help-body { flex: 1; padding: 24px 36px; }
.help-body ul { list-style: none; display: flex; flex-direction: column; gap: 18px; }
.help-body li {
  font-size: 19px; color: var(--text-secondary); line-height: 1.4;
  padding-left: 20px; position: relative;
}
.help-body li::before {
  content: ""; position: absolute; left: 0; top: 11px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.help-body b { color: var(--text-primary); }
