/* Gatotkoco: Sky Defender Nusantara — Styles */

:root {
  --sky-top: #4a90d9;
  --sky-mid: #87ceeb;
  --sky-bottom: #ffe4b5;
  --gold: #d4a017;
  --gold-light: #f4d03f;
  --batik-red: #8b1538;
  --batik-gold: #c9a227;
  --panel-bg: rgba(20, 30, 60, 0.92);
  --text: #fff8e7;
  --accent: #ff6b35;
  --success: #2ecc71;
  --danger: #e74c3c;
  --font-display: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-display);
  background: linear-gradient(180deg, #1a2a4a 0%, #2d4a6e 50%, #1a2a4a 100%);
  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.4rem 1rem;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.25rem;
  color: var(--gold-light);
  letter-spacing: 0.05em;
}

.header-sub {
  font-size: 0.75rem;
  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 32px rgba(0, 0, 0, 0.45);
  background: var(--sky-mid);
  touch-action: none;
}

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

.screen.hidden {
  display: none !important;
  pointer-events: none;
}

.screen.overlay-light {
  background: rgba(10, 20, 40, 0.35);
}

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

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

.panel-small {
  max-width: 340px;
}

.batik-border {
  border: 3px solid var(--batik-gold);
  box-shadow:
    inset 0 0 0 1px var(--batik-red),
    0 0 20px rgba(201, 162, 39, 0.25);
}

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

.panel-sub {
  font-size: 1rem;
  color: var(--sky-mid);
  margin-bottom: 0.5rem;
}

.panel-tag {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-bottom: 1rem;
}

.menu-record {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--gold);
}

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

.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.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  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 {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
  font-family: inherit;
}

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

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

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

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

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

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

.credit-text {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.credit-small {
  font-size: 0.75rem;
  opacity: 0.7;
  margin: 1rem 0;
}

.credit-small code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Level select */
.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
  text-align: left;
}

.level-btn {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  transition: background 0.15s;
}

.level-btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.15);
}

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

.level-btn.unlocked {
  border-color: var(--batik-gold);
}

.level-btn .lv-num {
  font-weight: 700;
  color: var(--gold-light);
}

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

.hud.hidden {
  display: none;
}

.hud-panel {
  background: rgba(10, 20, 40, 0.75);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.hud-label {
  min-width: 2.5rem;
}

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

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 5px;
  transition: width 0.2s;
}

.bar-health { background: linear-gradient(90deg, #c0392b, #e74c3c); }
.bar-energy { background: linear-gradient(90deg, #2980b9, #3498db); }
.bar-boss { background: linear-gradient(90deg, #8e44ad, #e74c3c); }

.boss-row.hidden { display: none; }

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

.hud-boss-name {
  font-size: 0.65rem;
  max-width: 4rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.7rem;
  margin-top: 0.25rem;
}

.hud-badges {
  margin-top: 0.35rem;
  font-size: 1rem;
  letter-spacing: 0.15em;
}

/* Mobile controls */
.mobile-controls {
  position: absolute;
  bottom: 0.5rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 0.75rem 0.25rem;
  z-index: 15;
  pointer-events: none;
}

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

.mobile-controls .touch-btn {
  pointer-events: auto;
}

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

.dpad-mid {
  display: flex;
  gap: 2px;
}

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

.touch-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 30, 60, 0.75);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.touch-btn:active,
.touch-btn.active {
  background: rgba(212, 160, 23, 0.6);
  border-color: var(--gold-light);
}

.touch-shoot {
  background: rgba(52, 152, 219, 0.7);
  font-size: 1.3rem;
}

.touch-special {
  background: rgba(155, 89, 182, 0.7);
  font-size: 1.2rem;
}

/* Education screens */
.edu-screen .edu-panel {
  max-width: 440px;
}

.edu-title {
  font-size: 1.25rem;
  color: var(--gold-light);
  margin-bottom: 0.75rem;
}

.edu-desc, .edu-progress {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.edu-question {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 1rem 0;
  color: #fff;
}

.edu-answers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.edu-answer-btn {
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  text-align: left;
  transition: background 0.15s;
}

.edu-answer-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.edu-feedback {
  margin-top: 1rem;
  min-height: 1.5rem;
  font-weight: 600;
}

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

.upgrade-info {
  margin: 1rem 0;
  font-size: 0.95rem;
}

.stat-line {
  margin: 0.5rem 0;
  font-size: 1rem;
}

.victory-title {
  color: var(--gold-light);
}

.victory-sub {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-bottom: 1rem;
}

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

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

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

/* Desktop: hide mobile controls on wide screens with keyboard */
@media (min-width: 900px) and (hover: hover) {
  .mobile-controls {
    display: none !important;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .panel {
    padding: 1rem 1.25rem;
  }

  .panel-title {
    font-size: 1.35rem;
  }

  .touch-btn {
    width: 46px;
    height: 46px;
    font-size: 1rem;
  }

  .hud-panel {
    max-width: 100%;
  }
}
