:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --bg-elevated: #28283a;
  --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.45);
  --radius-md: 12px;
  --radius-sm: 6px;
  --radius-lg: 18px;
}

* { 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', Roboto, sans-serif;
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#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, .hidden { display: none !important; }

.focusable {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 24px var(--focus-glow);
}

.btn {
  font-family: inherit;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 4px;
  height: 72px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* HOME ----------------------------------------------------------- */
#home {
  padding: 40px 60px;
  justify-content: center;
  align-items: center;
}
.home-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  width: 100%;
}
.brand {
  text-align: center;
}
.brand-line {
  font-weight: 200;
  line-height: 0.95;
  letter-spacing: 12px;
}
.brand-1 {
  font-size: 50px;
  color: var(--accent);
  margin-right: -12px;
}
.brand-2 {
  font-size: 50px;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: -12px;
  margin-top: 2px;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 6px;
  color: var(--text-muted);
  margin-top: 12px;
}
.best-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px 32px;
  text-align: center;
  min-width: 280px;
}
.best-label {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.best-row {
  font-size: 16px;
  color: var(--text-secondary);
}
.best-num {
  color: var(--accent-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.best-unit { color: var(--text-muted); margin-left: 4px; font-size: 13px; }
.best-sep { color: var(--text-muted); margin: 0 10px; }

.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 360px;
  margin-top: 4px;
}

/* GAME ----------------------------------------------------------- */
#game {
  padding: 14px 20px 10px;
}
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 6px 10px;
  border-bottom: 1px solid var(--bg-tertiary);
}
.stat {
  display: flex;
  flex-direction: column;
  min-width: 90px;
}
.stat-center { align-items: center; }
.stat-end { align-items: flex-end; }
.stat-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat-progress {
  color: var(--accent-secondary);
}

.board-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
}
.board {
  width: 460px;
  height: 460px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  background: var(--bg-primary);
  padding: 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
}
.tile {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 40px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  transition: background 0.15s ease, color 0.15s ease;
}
.tile.empty {
  background: transparent;
  color: transparent;
  border: 2px dashed rgba(0, 212, 255, 0.28);
}
.tile.correct {
  background: var(--bg-secondary);
  color: var(--accent-secondary);
}
.tile.last-moved {
  background: var(--accent);
  color: #000;
}

.game-footer {
  text-align: center;
  padding: 6px 0 2px;
}
.hint {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
}
.hint .kbd {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  margin: 0 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  letter-spacing: 1px;
}
.hint .dot { color: var(--text-muted); margin: 0 4px; }

/* WIN ------------------------------------------------------------ */
#win {
  padding: 36px 60px;
  justify-content: center;
  align-items: center;
}
.win-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}
.win-icon {
  font-size: 56px;
  line-height: 1;
  color: var(--accent-secondary);
}
.win-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 10px;
  color: var(--text-primary);
  margin-right: -10px;
}
.win-stats {
  display: flex;
  align-items: center;
  gap: 36px;
  background: var(--bg-secondary);
  padding: 16px 40px;
  border-radius: var(--radius-md);
}
.win-stat { text-align: center; }
.win-stat-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.win-stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.win-divider {
  width: 1px;
  height: 36px;
  background: var(--bg-tertiary);
}
.win-best {
  background: var(--accent-secondary);
  color: #000;
  padding: 8px 22px;
  border-radius: var(--radius-md);
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 13px;
}

/* HOW ------------------------------------------------------------ */
#how {
  padding: 30px 40px;
  justify-content: center;
}
.how-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.how-title {
  font-size: 26px;
  letter-spacing: 6px;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  margin-right: -6px;
}
.how-body {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--radius-md);
}
.how-body p {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 14px;
}
.how-body .ac { color: var(--accent); font-weight: 600; }
.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.how-cell {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}
.how-cell-wide { grid-column: span 2; }
.kbd {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  min-width: 36px;
  text-align: center;
  display: inline-block;
}
