:root {
  --bg-primary: #000000; /* pure black = transparent on additive display, lets real world show through */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #cfcfe0;
  --text-muted: #7a7a90;
  --accent-primary: #ff9f43;
  --accent-gold: #ffd166;
  --accent-red: #ff4d5e;
  --focus-ring: #ffd166;
  --focus-glow: rgba(255, 209, 102, 0.45);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { 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: 22px;
  font-weight: 600;
  flex: 1;
}
.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 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Focus States --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Buttons --- */
.nav-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.nav-item.primary {
  background: var(--accent-primary);
  color: #1a0a00;
}
.nav-item.primary:focus { background: #ffb968; }
.mt-auto { margin-top: auto; }

/* ==================== TITLE SCREEN ==================== */
.title-content {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}
.torii-art {
  position: relative;
  width: 220px;
  height: 140px;
  margin-bottom: 4px;
}
.torii {
  position: absolute;
  inset: 0;
}
.torii-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  background: var(--accent-red);
  border-radius: 4px;
}
.torii-bar-top { top: 0; height: 16px; }
.torii-bar-mid { top: 30px; height: 10px; left: 26px; right: 26px; }
.torii-pillar {
  position: absolute;
  top: 24px;
  bottom: 0;
  width: 16px;
  background: var(--accent-red);
  border-radius: 4px;
}
.torii-pillar-l { left: 34px; }
.torii-pillar-r { right: 34px; }
.bell {
  position: absolute;
  top: -6px;
  right: 22px;
  font-size: 28px;
  transform-origin: top center;
  animation: bell-idle 4s ease-in-out infinite;
}
@keyframes bell-idle {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}
.title-status {
  font-size: 15px;
  color: var(--text-secondary);
}
.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

/* ==================== SHAKE SCREEN ==================== */
.shake-content {
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.omikuji-box {
  position: relative;
  width: 120px;
  height: 150px;
  animation: shake-box 0.28s ease-in-out infinite;
}
@keyframes shake-box {
  0%, 100% { transform: rotate(-6deg) translateX(-4px); }
  50% { transform: rotate(6deg) translateX(4px); }
}
.box-body {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 110px;
  background: var(--bg-card);
  border: 3px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}
.box-lid {
  position: absolute;
  top: 0;
  left: -6px;
  right: -6px;
  height: 26px;
  background: var(--accent-red);
  border-radius: var(--radius-sm);
  z-index: 2;
}
.box-stick {
  margin-top: 30px;
  font-size: 34px;
  animation: stick-poke 0.28s ease-in-out infinite;
}
@keyframes stick-poke {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.shake-text {
  font-size: 16px;
  color: var(--text-secondary);
}

/* ==================== RESULT SCREEN ==================== */
.result-content {
  align-items: stretch;
}
.rank-display {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 4px;
}
.rank-kanji {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 4px;
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.5);
}
.cat-tabs {
  display: flex;
  gap: 6px;
}
.cat-tabs .tab-item {
  flex: 1;
  padding: 10px 4px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  text-align: center;
}
.cat-tabs .tab-item.active {
  background: var(--bg-card);
  color: var(--accent-gold);
}
.cat-message-box {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 78px;
  display: flex;
  align-items: center;
}
.cat-message {
  font-size: 16px;
  line-height: 1.5;
}
.advice-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.advice-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.advice-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==================== HISTORY SCREEN ==================== */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 400px;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  text-align: left;
}
.list-item-date { color: var(--text-secondary); }
.list-item-rank {
  font-weight: 700;
  color: var(--accent-gold);
  font-size: 17px;
}
.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 15px;
}
