:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --gold: #D4A843;
  --brown: #8B4513;
  --rust: #C75B39;
  --focus-ring: #D4A843;
  --focus-glow: rgba(212, 168, 67, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
}

* { 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;
}

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

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

.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.nav-item.primary {
  background: var(--gold);
  color: #0a0a0f;
}
.nav-item.primary:focus { background: #e8be57; }

.hidden { display: none !important; }

/* Title Screen */
.center-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: radial-gradient(ellipse at center, #1a1508 0%, #000 70%);
}
.title-star {
  font-size: 64px;
  color: var(--gold);
  margin-bottom: 12px;
}
.title-star.dead { color: var(--rust); }
.title-star.win { color: #FFD700; }
.game-title {
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  color: var(--gold);
  line-height: 1.2;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.8), 0 0 24px rgba(212,168,67,0.5);
}
.title-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
  margin-bottom: 30px;
}
.title-hi {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 20px;
}
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 260px;
}
.menu-btn {
  padding: 16px 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.8);
}
.menu-btn:focus { background: var(--bg-card); }
.toggle-btn {
  font-size: 14px;
  padding: 12px 24px;
  color: var(--text-secondary);
}
.toggle-btn.off { color: var(--text-muted); }

/* How To Play */
.howto-content {
  gap: 16px;
  padding: 24px;
}
.howto-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 20px;
}
.howto-key {
  background: var(--bg-card);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
  color: var(--gold);
}
.howto-label {
  background: var(--rust);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
}
.howto-divider {
  border-top: 1px solid var(--bg-card);
  margin: 4px 0;
}
.howto-tip {
  font-size: 19px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 600;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.8);
}

/* Game Canvas */
#gameCanvas {
  display: block;
  width: 600px;
  height: 600px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Shop */
.shop-header {
  background: linear-gradient(180deg, #1a1508 0%, var(--bg-secondary) 100%);
}
.shop-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  gap: 12px;
}
.shop-item:focus { background: var(--bg-card); }
.shop-item.sold-out { opacity: 0.4; }
.shop-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
}
.shop-info { flex: 1; min-width: 0; }
.shop-name {
  font-weight: 600;
  font-size: 16px;
}
.shop-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.shop-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}
.shop-price.cant-afford { color: var(--rust); }
.shop-tier {
  font-size: 12px;
  color: var(--text-muted);
}

/* Game Over / Victory */
.go-title {
  font-size: 36px;
  font-weight: 800;
  color: var(--rust);
  margin-bottom: 8px;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.8), 0 0 20px rgba(199,91,57,0.4);
}
.victory-title {
  font-size: 36px;
  font-weight: 800;
  color: #FFD700;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.8), 0 0 24px rgba(255,215,0,0.5);
  margin-bottom: 8px;
}
.victory-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.go-stats {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
