:root {
  --bg: #1a1520;
  --panel: #2a2233;
  --panel-2: #352b40;
  --text: #f3e9d7;
  --muted: #a89888;
  --gold: #f0c14a;
  --hp: #e85d5d;
  --accent: #7bc96f;
  --arrow: #d4a574;
  --magic: #9b7ed9;
  --fence: #8b6914;
  --danger: #ff6b6b;
  --easy: #7bc96f;
  --normal: #f0c14a;
  --hard: #e85d5d;
  --radius: 12px;
  --font: "Segoe UI", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: radial-gradient(ellipse at top, #2d2438 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  user-select: none;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

#app {
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.screen.active {
  display: flex;
}

/* Menu */
.menu-card {
  background: var(--panel);
  border: 1px solid #463850;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  margin: 40px auto;
  text-align: center;
}

.menu-card h2 {
  margin-bottom: 8px;
}

.menu-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.difficulty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.diff-btn {
  border: 2px solid #564860;
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: 0.15s;
  text-align: left;
}

.diff-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.diff-btn .name {
  font-weight: 700;
  display: block;
}

.diff-btn .desc {
  font-size: 0.8rem;
  color: var(--muted);
}

.diff-btn[data-diff="easy"] .name { color: var(--easy); }
.diff-btn[data-diff="normal"] .name { color: var(--normal); }
.diff-btn[data-diff="hard"] .name { color: var(--hard); }

/* HUD */
.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}

.hud-item {
  background: var(--panel);
  border: 1px solid #463850;
  border-radius: 10px;
  padding: 8px 10px;
}

.hud-item .label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.hud-item .value {
  font-size: 1.15rem;
  font-weight: 700;
}

.hud-item.gold .value { color: #f0c14a; }
.hud-item.hp .value { color: var(--hp); }
.hud-item.wave .value { color: #7ec8e3; }

/* Layout */
.play-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
}

@media (max-width: 800px) {
  .play-layout {
    grid-template-columns: 1fr;
  }
}

.canvas-wrap {
  background: var(--panel);
  border: 1px solid #463850;
  border-radius: var(--radius);
  padding: 8px;
  overflow: auto;
  position: relative;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  cursor: crosshair;
  background: #3d5c3a;
  border-radius: 8px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid #463850;
  border-radius: var(--radius);
  padding: 10px;
}

.panel h3 {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool {
  border: 2px solid #564860;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
  transition: 0.12s;
}

.tool:hover { border-color: #7a6a80; }
.tool.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.tool .cost {
  float: right;
  color: #f0c14a;
  font-weight: 700;
}

.tool.arrow-t { border-left: 4px solid var(--arrow); }
.tool.magic-t { border-left: 4px solid var(--magic); }
.tool.fence-t { border-left: 4px solid var(--fence); }
.tool.chicken-t { border-left: 4px solid #f5d76e; }
.tool.sell-t { border-left: 4px solid var(--danger); }

.egg-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #564860;
}

.btn:hover { filter: brightness(1.1); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #6dbf62, #4a9a42);
  border-color: #3d7a38;
  color: #fff;
}

.btn.danger {
  background: linear-gradient(180deg, #e07070, #c04040);
  border-color: #a03030;
  color: #fff;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.log {
  font-size: 0.75rem;
  color: var(--muted);
  max-height: 90px;
  overflow-y: auto;
  line-height: 1.35;
}

.log div { margin-bottom: 2px; }

/* Overlay */
.overlay {
  position: absolute;
  inset: 8px;
  background: rgba(20, 14, 24, 0.82);
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 5;
  text-align: center;
  padding: 20px;
}

.overlay.active { display: flex; }

.overlay h2 { font-size: 1.6rem; }
.overlay p { color: var(--muted); }
