/* Gatotkoco Pintar — gaya kartun cerah, wayang ramah anak */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@600;700&display=swap');

:root {
  --sky: #87ceeb;
  --sky-deep: #5ba3d9;
  --gold: #ffb347;
  --gold-dark: #e8942a;
  --red: #ff6b6b;
  --green: #51cf66;
  --purple: #9775fa;
  --cream: #fff9e6;
  --brown: #5c4033;
  --panel: #fff8e7;
  --shadow: rgba(60, 40, 20, 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, #ffe8b8 0%, var(--sky) 40%, #b8e0ff 100%);
  min-height: 100vh;
  color: var(--brown);
  display: flex;
  justify-content: center;
  padding: 0.5rem;
}

.app { width: 100%; max-width: 940px; text-align: center; }

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 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(--brown);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}

.lang-btn.active { background: var(--gold); }

.header-title {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.4rem, 5vw, 2rem);
  color: var(--gold-dark);
  text-shadow: 2px 2px 0 #fff;
}

.header-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--purple);
}

.game-shell {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  border: 5px solid var(--gold);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px var(--shadow);
  background: var(--sky);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
}

/* HUD */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  padding: 8px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.85), transparent);
}

.hud.hidden { display: none; }

.hud-panel {
  background: rgba(255, 248, 231, 0.95);
  border: 3px solid var(--gold);
  border-radius: 12px;
  padding: 6px 10px;
  min-width: 180px;
}

.hud-row {
  display: grid;
  grid-template-columns: 42px 1fr 28px;
  gap: 4px;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.bar {
  height: 10px;
  background: #ddd;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--brown);
}

.fill { height: 100%; width: 100%; transition: width 0.2s; }
.fill.health { background: linear-gradient(90deg, #ff8787, var(--red)); }
.fill.energy { background: linear-gradient(90deg, #74c0fc, #339af0); }

.hud-stats {
  display: flex;
  gap: 10px;
  font-size: 0.68rem;
  border-top: 2px dashed var(--gold);
  padding-top: 4px;
  margin-top: 2px;
}

.hud-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 120px;
  align-content: flex-start;
}

.mini-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--brown);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(91, 163, 217, 0.75);
  padding: 12px;
}

.screen.hidden { display: none; }

.panel {
  background: var(--panel);
  border: 4px solid var(--gold);
  border-radius: 20px;
  padding: 1.5rem;
  max-width: 95%;
  box-shadow: 0 8px 24px var(--shadow);
}

.panel-scroll { max-height: 85%; overflow-y: auto; }

.panel-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.6rem;
  color: var(--gold-dark);
  margin-bottom: 0.25rem;
}

.panel-title.win { color: var(--green); }
.panel-title.sad { color: var(--red); }

.panel-sub { color: var(--purple); font-weight: 700; font-size: 0.9rem; }
.panel-info { font-size: 0.8rem; margin: 0.5rem 0; }
.menu-record { font-weight: 700; color: var(--gold-dark); margin-bottom: 1rem; }
.big-score { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem; }

.btn {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0.35rem auto;
  padding: 0.65rem 1rem;
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  border-radius: 12px;
  border: 3px solid var(--brown);
  cursor: pointer;
  transition: transform 0.1s;
}

.btn:active { transform: scale(0.96); }
.btn-main { background: linear-gradient(180deg, var(--green), #37b24d); color: #fff; }
.btn-sub { background: #fff; color: var(--brown); }
.sound-check { display: block; margin-top: 0.75rem; font-size: 0.8rem; }

.help-list {
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 1rem 0;
  padding-left: 1.2rem;
}
.credit-small { font-size: 0.75rem; opacity: 0.8; margin-top: 0.5rem; }
.credit-small code { color: var(--purple); }

/* Edu screens */
.edu-panel { max-width: 420px; width: 100%; }
.edu-title { font-family: 'Fredoka', sans-serif; color: var(--purple); margin-bottom: 0.5rem; }
.edu-desc, .edu-hint { font-size: 0.85rem; margin-bottom: 0.75rem; }
.edu-question {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 1rem 0;
  color: var(--brown);
}
.moral-q { font-size: 1rem; line-height: 1.4; }

.edu-answers { display: flex; flex-direction: column; gap: 8px; }
.edu-btn {
  padding: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  border: 3px solid var(--brown);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}
.edu-btn:hover { background: #e7f5ff; }
.edu-btn.correct { background: #d3f9d8; border-color: var(--green); }
.edu-btn.wrong { background: #ffe3e3; border-color: var(--red); }

.edu-feedback {
  min-height: 1.5rem;
  margin-top: 0.75rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.reading-slots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.reading-slot {
  width: 44px;
  height: 48px;
  border: 3px dashed var(--gold-dark);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  background: #fff;
}

.reading-letters {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.letter-btn {
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 10px;
  border: 3px solid var(--purple);
  background: #f3f0ff;
  cursor: pointer;
}

.letter-btn.used { opacity: 0.35; pointer-events: none; }

.boss-panel { text-align: center; }
.boss-warn { color: var(--red); font-weight: 700; font-size: 1.1rem; }

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

.badge-item {
  text-align: center;
  font-size: 0.75rem;
  max-width: 72px;
}
.badge-item span { font-size: 2rem; display: block; }

.victory-panel { max-width: 400px; }

/* Touch */
.touch {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 12px 14px;
}
.touch.hidden { display: none; }
.touch .tbtn { pointer-events: auto; touch-action: manipulation; }

.dpad { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dpad-mid { display: flex; gap: 4px; }

.tbtn {
  width: 50px; height: 50px;
  font-size: 1.1rem;
  border-radius: 12px;
  border: 3px solid var(--brown);
  background: rgba(255,255,255,0.9);
  color: var(--brown);
  font-weight: 700;
}
.tbtn:active { background: var(--gold); }
.t-attack {
  width: 58px; height: 58px;
  font-size: 1.4rem;
  background: linear-gradient(180deg, #ffd43b, var(--gold));
  align-self: center;
}

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

@media (max-width: 900px), (pointer: coarse) {
  .touch:not(.hidden) { display: flex; }
}
