/* Gatotkoco Runner Adventure */

:root {
  --gold: #d4a017;
  --gold-light: #f4d03f;
  --batik-red: #8b1538;
  --batik-gold: #c9a227;
  --panel-bg: rgba(20, 30, 60, 0.94);
  --text: #fff8e7;
  --success: #2ecc71;
  --danger: #e74c3c;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #1a2a4a, #2d4a6e);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

.header {
  text-align: center;
  padding: 0.35rem 1rem;
  flex-shrink: 0;
}

.header-title { font-size: 1.2rem; color: var(--gold-light); }
.header-sub { font-size: 0.72rem; opacity: 0.85; }

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

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 960px;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  background: #87ceeb;
  touch-action: none;
  position: relative;
  z-index: 1;
}

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

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

.panel {
  background: var(--panel-bg);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

.panel-scroll { max-height: 88vh; overflow-y: auto; }

.batik-border {
  border: 3px solid var(--batik-gold);
  box-shadow: inset 0 0 0 1px var(--batik-red);
}

.panel-title { font-size: 1.45rem; color: var(--gold-light); margin-bottom: 0.25rem; }
.panel-sub { font-size: 0.95rem; opacity: 0.9; }
.panel-tag { font-size: 0.78rem; opacity: 0.75; margin: 0.5rem 0 1rem; }

.menu-record { font-size: 0.85rem; color: var(--gold); margin-bottom: 1rem; }
.menu-nav { display: flex; flex-direction: column; gap: 0.5rem; }

.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: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-lang.active {
  background: rgba(212, 160, 23, 0.35);
  border-color: var(--batik-gold);
  box-shadow: 0 0 0 2px var(--gold-light);
}

.btn {
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}

.btn-main {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #1a1a2e;
}

.btn-sub {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.hidden { display: none; }

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

.help-list li { margin-bottom: 0.45rem; }

/* HUD */
.hud {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  right: 0.4rem;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: flex-start;
}

.hud.hidden { display: none; }

.hud-panel {
  background: rgba(10, 20, 40, 0.8);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  margin-bottom: 0.25rem;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill { height: 100%; transition: width 0.2s; }
.bar-fill.health { background: #e74c3c; }
.bar-fill.energy { background: #3498db; }

.hud-num { min-width: 1.8rem; text-align: right; font-weight: 600; font-size: 0.68rem; }

.hud-stats, .hud-letters {
  font-size: 0.65rem;
  margin-top: 0.15rem;
}

.hud-powers {
  display: flex;
  gap: 4px;
  pointer-events: auto;
}

.power-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 30, 60, 0.85);
  font-size: 1.1rem;
  cursor: pointer;
}

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

/* Mobile */
.mobile-controls {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 15;
}

.mobile-controls.hidden { display: none; }

.touch-btn {
  padding: 0.65rem 1rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(20, 30, 60, 0.8);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
}

.touch-btn.active { background: rgba(212, 160, 23, 0.7); }
.touch-jump { background: rgba(46, 204, 113, 0.5); }
.touch-slide { background: rgba(52, 152, 219, 0.5); }

/* Word puzzle UI */
.word-slots {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 1rem 0 0.75rem;
}

.word-slot {
  width: 44px;
  height: 48px;
  border: 2px dashed var(--batik-gold);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.word-slot.filled { border-style: solid; background: rgba(212, 160, 23, 0.25); }

.word-pool {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.letter-tile {
  width: 44px;
  height: 48px;
  border-radius: 8px;
  border: 2px solid var(--batik-gold);
  background: linear-gradient(180deg, #5d4e37, #3e2723);
  color: var(--gold-light);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
}

.letter-tile:hover { transform: scale(1.05); }
.letter-tile.used { opacity: 0.3; pointer-events: none; }

.edu-desc, .puzzle-hint, .practice-hint { font-size: 0.85rem; opacity: 0.9; }
.practice-category { font-size: 0.8rem; color: var(--gold); margin-bottom: 0.5rem; }

.edu-feedback { min-height: 1.4rem; font-weight: 600; margin: 0.5rem 0; }
.edu-feedback.ok { color: var(--success); }
.edu-feedback.bad { color: var(--danger); }

.stat-line { margin: 0.4rem 0; font-size: 0.95rem; }

.badge-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0.75rem 0;
}

.badge-item {
  background: rgba(212, 160, 23, 0.2);
  border: 1px solid var(--batik-gold);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
}

.report-content {
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 1rem 0;
}

.report-content h3 {
  font-size: 0.9rem;
  color: var(--gold-light);
  margin: 0.75rem 0 0.35rem;
}

.report-content ul { padding-left: 1.2rem; }

.hit-toast {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(231, 76, 60, 0.9);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  z-index: 12;
  pointer-events: none;
  animation: fadeToast 1.2s ease forwards;
}

.hit-toast.hidden { display: none; }

@keyframes fadeToast {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

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

@media (min-width: 900px) and (hover: hover) {
  .mobile-controls { display: none !important; }
}

@media (max-width: 480px) {
  .touch-btn { padding: 0.55rem 0.75rem; font-size: 0.78rem; }
  .power-btn { width: 36px; height: 36px; font-size: 0.95rem; }
}
