/* Gatotkoco Math Warriors — cute wayang cartoon style */

:root {
  --gold: #f4c430;
  --gold-dark: #d4a017;
  --batik-red: #c0392b;
  --batik-gold: #e8b923;
  --sky: #87ceeb;
  --grass: #58d68d;
  --panel: rgba(30, 45, 90, 0.95);
  --text: #fffef5;
  --cute-pink: #ff9ff3;
  --cute-orange: #ff9f43;
  --success: #2ecc71;
  --danger: #ff6b6b;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Comic Sans MS", "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(160deg, #6c5ce7 0%, #a29bfe 40%, #fd79a8 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.header { text-align: center; padding: 0.35rem; flex-shrink: 0; }
.header-title { font-size: 1.2rem; color: var(--gold); text-shadow: 2px 2px 0 #8b4513; }
.header-sub { font-size: 0.75rem; }

.game-shell {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 0.5rem;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  border: 4px solid var(--batik-gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  background: var(--sky);
  position: relative;
  z-index: 1;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  z-index: 25;
  background: rgba(20, 30, 70, 0.5);
  pointer-events: auto;
}

.screen.hidden { display: none !important; }

.panel {
  background: var(--panel);
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
}

.panel-scroll { max-height: 88vh; overflow-y: auto; }
.map-panel { max-width: 520px; }

.batik-border {
  border: 4px solid var(--batik-gold);
  box-shadow: 0 0 0 2px var(--batik-red), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.panel-title {
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.panel-sub { font-size: 1rem; color: #dfe6e9; }
.panel-tag { font-size: 0.78rem; opacity: 0.85; margin: 0.4rem 0 0.75rem; }
.panel-desc { font-size: 0.85rem; margin-bottom: 1rem; opacity: 0.9; }
.menu-stats { color: var(--gold); font-size: 0.88rem; margin-bottom: 1rem; }

.menu-nav { display: flex; flex-direction: column; gap: 0.55rem; }

.lang-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.lang-row .btn-lang {
  flex: 1;
  padding: 0.65rem 0.5rem;
  font-size: 0.85rem;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-lang.active {
  background: rgba(244, 196, 48, 0.35);
  border-color: var(--batik-gold);
  box-shadow: 0 0 0 2px var(--gold);
}

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

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

.btn-main {
  background: linear-gradient(180deg, #ffeaa7, var(--gold));
  color: #2d3436;
  box-shadow: 0 4px 0 #b8860b;
}

.btn-sub {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.btn-jurus {
  margin-top: 0.5rem;
  background: linear-gradient(180deg, #a29bfe, #6c5ce7);
  color: #fff;
  box-shadow: 0 4px 0 #4834d4;
}

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

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

/* Grade list */
.grade-list, .map-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.grade-btn, .map-btn {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  min-height: 52px;
}

.grade-btn.selected, .map-btn:not(:disabled):hover {
  border-color: var(--gold);
  background: rgba(244, 196, 48, 0.25);
}

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

.map-btn .map-icon { font-size: 1.3rem; margin-right: 0.5rem; }

/* Battle HUD */
.battle-hud {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  pointer-events: none;
}

.battle-hud.hidden { display: none; }

.hud-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.hud-block {
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
}

.hud-name { font-weight: 700; color: var(--gold); }

.bar-track {
  height: 12px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  overflow: hidden;
  margin: 0.25rem 0;
}

.bar-fill { height: 100%; transition: width 0.3s; border-radius: 6px; }
.hp-player { background: linear-gradient(90deg, #00b894, #55efc4); }
.hp-enemy { background: linear-gradient(90deg, #e17055, #fab1a0); }

.hud-mid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
}

.combo-meter-wrap {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  margin-top: 0.3rem;
  overflow: hidden;
}

.bar-combo {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #fdcb6e, #e17055, #6c5ce7);
  transition: width 0.25s;
  border-radius: 4px;
}

/* Math panel */
.math-panel {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 1.5rem);
  max-width: 420px;
  z-index: 15;
  background: var(--panel);
  border: 3px solid var(--batik-gold);
  border-radius: 16px;
  padding: 1rem;
  pointer-events: auto;
}

.math-panel.hidden { display: none; }

.math-timer { font-size: 0.85rem; color: var(--cute-orange); margin-bottom: 0.25rem; }
.math-question { font-size: 1.6rem; font-weight: 800; margin: 0.5rem 0; color: #fff; }

.math-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.math-answer-btn {
  padding: 0.85rem;
  font-size: 1.2rem;
  font-weight: 700;
  border: 3px solid var(--batik-gold);
  border-radius: 12px;
  background: linear-gradient(180deg, #74b9ff, #0984e3);
  color: #fff;
  cursor: pointer;
  min-height: 56px;
}

.math-answer-btn:active { transform: scale(0.96); }
.math-answer-btn.correct { background: linear-gradient(180deg, #55efc4, #00b894); }
.math-answer-btn.wrong { background: linear-gradient(180deg, #ff7675, #d63031); }

.math-feedback {
  min-height: 1.3rem;
  margin-top: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.math-feedback.ok { color: var(--success); }
.math-feedback.bad { color: var(--danger); }

.jurus-ready {
  color: var(--cute-pink);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.stat-line { margin: 0.4rem 0; }
.badge-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; margin: 0.75rem 0; }
.badge-item {
  background: rgba(244, 196, 48, 0.25);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
}

.dashboard-content { text-align: left; font-size: 0.85rem; line-height: 1.6; }
.dashboard-content h3 { color: var(--gold); font-size: 0.95rem; margin: 0.6rem 0 0.3rem; }
.dashboard-content ul { padding-left: 1.2rem; }

.bonus-progress { margin-bottom: 0.5rem; color: var(--gold); }
.practice-score { margin: 0.75rem 0; }

.attack-flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  border-radius: 16px;
}

.attack-flash.player-hit {
  background: rgba(255, 107, 107, 0.35);
  animation: flash 0.4s ease;
}

.attack-flash.enemy-hit {
  background: rgba(255, 235, 59, 0.4);
  animation: flash 0.35s ease;
}

.attack-flash.hidden { display: none; }

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.footer { text-align: center; font-size: 0.62rem; opacity: 0.6; padding: 0.2rem; flex-shrink: 0; }

@media (max-width: 480px) {
  .math-question { font-size: 1.35rem; }
  .math-answer-btn { font-size: 1.05rem; min-height: 52px; }
}
