/* Gatotkoco Village Builder — cute Nusantara / wayang theme */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@600;700;800&display=swap');

:root {
  --earth: #5c4033;
  --grass: #7cb342;
  --grass-dark: #558b2f;
  --sky: #87ceeb;
  --cream: #fff8e7;
  --gold: #ffb300;
  --terracotta: #e65100;
  --teal: #00897b;
  --pink: #f48fb1;
  --panel: rgba(255, 248, 231, 0.96);
  --border: #8d6e63;
  --shadow: rgba(92, 64, 51, 0.25);
}

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

html, body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(180deg, var(--sky) 0%, #c8e6c9 40%, var(--grass) 100%);
  min-height: 100vh;
  color: var(--earth);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem;
  text-align: center;
}

.top-bar { margin-bottom: 0.5rem; }

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.header-text { flex: 1; text-align: center; }

.lang-switch { display: flex; gap: 4px; flex-shrink: 0; }

.lang-btn {
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--earth);
  cursor: pointer;
  font-family: inherit;
}

.lang-btn.active {
  background: var(--teal);
  color: #fff;
  border-color: #00695c;
}

.logo {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  color: var(--terracotta);
  text-shadow: 2px 2px 0 var(--gold);
}

.tagline { font-size: 0.8rem; opacity: 0.9; }

.game-shell { position: relative; min-height: 60vh; }

.screen {
  display: none;
  padding: 0.5rem;
}

.screen.active { display: block; }

.screen.hidden { display: none; }

.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.overlay-screen.active { display: flex; }

.panel {
  background: var(--panel);
  border: 4px solid var(--border);
  border-radius: 20px;
  padding: 1.25rem;
  max-width: 420px;
  margin: 0 auto;
  box-shadow: 8px 8px 0 var(--shadow);
}

.scroll-panel { max-width: 520px; max-height: 80vh; overflow-y: auto; text-align: left; }

.wayang-frame {
  border: 3px solid var(--gold);
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe082, #ffcc80);
  padding: 0.5rem;
  display: inline-block;
}

.menu-panel .hero { font-size: 3rem; margin-bottom: 0.5rem; }

.subtitle { font-size: 0.85rem; margin-bottom: 0.75rem; }

.menu-stats { font-size: 0.75rem; color: var(--teal); margin-bottom: 1rem; }

.btn {
  display: block;
  width: 100%;
  margin: 0.35rem 0;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  min-height: 48px;
}

.btn.primary {
  background: linear-gradient(180deg, var(--teal), #00695c);
  color: #fff;
}

.btn.secondary {
  background: #fff;
  color: var(--earth);
  border: 2px solid var(--border);
}

.btn.warn {
  background: linear-gradient(180deg, #ff9800, var(--terracotta));
  color: #fff;
}

.btn:active { transform: scale(0.98); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.help-list {
  margin: 1rem 0;
  padding-left: 1.2rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

.guide-body, .report-body { font-size: 0.85rem; line-height: 1.6; }

.guide-item {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border-left: 4px solid var(--teal);
}

.credits-text { text-align: center; line-height: 1.7; font-size: 0.9rem; }

/* Game layout */
.game-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  text-align: left;
}

@media (min-width: 800px) {
  .game-layout {
    grid-template-columns: 160px 1fr 140px;
    align-items: start;
  }
}

.hud-side, .build-side {
  background: var(--panel);
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: 4px 4px 0 var(--shadow);
}

.hud-resources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.res-chip {
  background: #fff;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.hud-level {
  margin: 0.75rem 0;
  font-size: 0.8rem;
  text-align: center;
}

.hud-level strong { font-size: 1.4rem; color: var(--teal); display: block; }

.mission-box {
  font-size: 0.75rem;
  background: #e8f5e9;
  padding: 0.5rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.guide-box {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
}

.guide-avatar { font-size: 1.5rem; flex-shrink: 0; }

.board-wrap {
  background: var(--panel);
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 0.5rem;
  box-shadow: 4px 4px 0 var(--shadow);
  text-align: center;
}

#villageCanvas {
  width: 100%;
  max-width: 520px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  cursor: crosshair;
  touch-action: none;
}

.build-hint { font-size: 0.7rem; margin-top: 0.35rem; opacity: 0.8; }

.build-side h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.build-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.build-btn {
  padding: 0.6rem 4px;
  font-size: 0.65rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.build-btn .icon { font-size: 1.3rem; }

.build-btn.selected {
  border-color: var(--teal);
  background: #e0f2f1;
  box-shadow: 0 0 0 2px var(--teal);
}

.build-btn.locked { opacity: 0.4; pointer-events: none; }

.build-cost { font-size: 0.65rem; margin-top: 0.5rem; text-align: center; color: var(--terracotta); }

.event-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: linear-gradient(135deg, #fff9c4, #ffe082);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 1rem 1.5rem;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px var(--shadow);
  pointer-events: none;
}

.event-banner.hidden { display: none; }

.event-banner p { font-weight: 700; font-size: 0.9rem; }

.decision-btns { display: flex; flex-direction: column; gap: 8px; margin: 1rem 0; }

.decision-btns .btn { width: 100%; }

.feedback { font-size: 0.85rem; min-height: 1.2em; margin-top: 0.5rem; }

.lesson-panel { text-align: center; max-width: 400px; }

.lesson-panel h2 { color: var(--teal); margin-bottom: 0.75rem; }

.big-stat { font-size: 1.3rem; font-weight: 800; color: var(--terracotta); margin: 0.5rem 0; }

.stat-line { font-size: 0.85rem; margin: 0.25rem 0; }

.win { color: var(--teal); }

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 1rem 0;
}

.badge-pill {
  padding: 0.35rem 0.65rem;
  border-radius: 20px;
  background: #fff3e0;
  border: 1px solid var(--gold);
  font-size: 0.7rem;
}

.badge-pill.locked { opacity: 0.4; }

.footer {
  font-size: 0.7rem;
  opacity: 0.75;
  margin-top: 0.75rem;
}

@media (max-width: 799px) {
  .build-toolbar { grid-template-columns: repeat(4, 1fr); }
  .hud-resources { grid-template-columns: repeat(3, 1fr); }
}
