/* ============================================================
   Gatotkoco v2 — wayang / batik (emas, merah, hitam)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Noto+Sans:wght@400;600&display=swap');

:root {
  --gold: #c9a227;
  --gold-light: #e8c547;
  --red: #8b1a1a;
  --red-bright: #c41e3a;
  --black: #1a0f0a;
  --cream: #f5e6c8;
  --batik-brown: #3d2914;
  --shadow: rgba(0, 0, 0, 0.6);
  --energy-blue: #4fc3f7;
}

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

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

body {
  min-height: 100vh;
  font-family: 'Noto Sans', sans-serif;
  background:
    radial-gradient(ellipse at 50% 0%, #2a1810 0%, var(--black) 70%),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 12px,
      rgba(201, 162, 39, 0.03) 12px,
      rgba(201, 162, 39, 0.03) 24px
    );
  color: var(--cream);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

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

.page-header {
  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(--gold);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--cream);
  cursor: pointer;
  font-family: inherit;
}

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

.page-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  color: var(--gold-light);
  letter-spacing: 0.12em;
}

.page-subtitle {
  font-size: 0.75rem;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.version-badge {
  display: inline-block;
  padding: 0.1em 0.45em;
  background: var(--red);
  border-radius: 3px;
  font-size: 0.7em;
  vertical-align: middle;
}

.game-container {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 900px;
  border: 4px solid var(--gold);
  border-radius: 4px;
  box-shadow:
    0 0 0 2px var(--red),
    0 8px 32px var(--shadow);
  background: var(--black);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

/* ---------- HUD (HTML saja — tidak digambar di canvas) ---------- */
.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px 12px;
  background: linear-gradient(180deg, rgba(26, 15, 10, 0.9) 0%, rgba(26, 15, 10, 0.35) 70%, transparent 100%);
  pointer-events: none;
}

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

.hud-panel {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(260px, 72vw);
  padding: 6px 8px;
  background: rgba(26, 15, 10, 0.55);
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 4px;
}

.hud-row {
  display: grid;
  grid-template-columns: 44px 1fr 32px;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.hud-row:last-of-type {
  margin-bottom: 4px;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.bar-track {
  height: 11px;
  min-width: 0;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--gold);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.15s ease-out;
  border-radius: 2px;
}

.bar-health {
  background: linear-gradient(90deg, var(--red) 0%, var(--red-bright) 100%);
}

.bar-energy {
  background: linear-gradient(90deg, #2a6a8a 0%, var(--energy-blue) 100%);
}

.hud-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--cream);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hud-stats {
  display: flex;
  gap: 12px;
  padding-top: 2px;
  font-size: 0.68rem;
  color: var(--cream);
  opacity: 0.92;
  border-top: 1px solid rgba(201, 162, 39, 0.25);
  margin-top: 2px;
  padding-top: 4px;
}

.hud-stats strong {
  color: var(--gold-light);
}

.hud-rekor {
  flex-shrink: 0;
  font-size: 0.68rem;
  color: var(--cream);
  padding: 6px 8px;
  background: rgba(26, 15, 10, 0.55);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 4px;
  white-space: nowrap;
}

.hud-rekor strong {
  color: var(--gold-light);
}

/* ---------- Overlay screens ---------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 15, 10, 0.88);
  z-index: 10;
  padding: 0.75rem;
}

.overlay-screen.hidden {
  display: none;
}

.screen-panel {
  padding: 1.5rem 1.75rem;
  background: linear-gradient(160deg, #2a1810 0%, var(--black) 100%);
  border-radius: 6px;
  max-width: 100%;
  max-height: 90%;
  overflow-y: auto;
}

.batik-border {
  border: 3px solid var(--gold);
  box-shadow:
    inset 0 0 0 1px var(--red),
    0 0 0 6px var(--batik-brown),
    0 0 0 8px var(--gold),
    0 12px 40px var(--shadow);
}

.menu-panel {
  min-width: 260px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.menu-high-score {
  font-size: 0.95rem;
  color: var(--gold-light);
  margin-bottom: 1rem;
}

.scroll-panel {
  max-width: 420px;
}

.game-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.35rem, 5vw, 2rem);
  color: var(--gold-light);
  margin-bottom: 0.35rem;
}

.game-tagline {
  font-size: 0.8rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

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

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

/* Boss warning */
.boss-warning .boss-panel {
  text-align: center;
}

.boss-warning-label {
  color: var(--red-bright);
  font-weight: 700;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
}

.boss-warning-title {
  color: #ff6600;
}

.boss-warning-text {
  margin: 0.75rem 0;
  opacity: 0.9;
}

.boss-countdown {
  font-family: 'Cinzel', serif;
  font-size: 3rem;
  color: var(--gold-light);
  margin: 0.5rem 0;
}

.game-over-title {
  color: var(--red-bright);
}

.final-score, .final-high {
  font-size: 1.1rem;
  color: var(--gold-light);
  margin-bottom: 0.35rem;
}

.new-record {
  color: var(--gold-light);
  font-weight: 700;
  margin-bottom: 1rem;
  animation: pulse 0.8s ease infinite alternate;
}

.new-record.hidden {
  display: none;
}

@keyframes pulse {
  from { opacity: 0.7; transform: scale(1); }
  to { opacity: 1; transform: scale(1.05); }
}

/* Buttons */
.btn-primary, .btn-secondary {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  padding: 0.65rem 1.5rem;
  width: 100%;
  max-width: 240px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin: 0.25rem auto;
  display: block;
}

.btn-primary {
  background: linear-gradient(180deg, var(--red-bright) 0%, var(--red) 100%);
  color: var(--cream);
  border: 2px solid var(--gold);
}

.btn-secondary {
  background: transparent;
  color: var(--cream);
  border: 2px solid var(--gold);
}

.btn-primary:hover, .btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.sound-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.sound-toggle input {
  accent-color: var(--gold);
}

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

.page-footer code {
  color: var(--gold);
}

/* Touch controls */
.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 12px 16px;
}

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

.touch-controls .touch-btn {
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
}

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

.dpad-row {
  display: flex;
  gap: 4px;
}

.touch-btn {
  width: clamp(48px, 14vw, 58px);
  height: clamp(48px, 14vw, 58px);
  font-size: 1.15rem;
  color: var(--cream);
  background: rgba(26, 15, 10, 0.82);
  border: 2px solid var(--gold);
  border-radius: 10px;
}

.touch-btn:active, .touch-btn.active {
  background: rgba(196, 30, 58, 0.9);
  transform: scale(0.94);
}

.touch-attack {
  width: clamp(56px, 16vw, 68px);
  height: clamp(56px, 16vw, 68px);
  font-size: 1.45rem;
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  align-self: center;
  margin-bottom: 4px;
}

@media (max-width: 900px), (hover: none), (pointer: coarse) {
  .touch-controls:not(.hidden) {
    display: flex;
  }
  .hud-rekor {
    font-size: 0.62rem;
    padding: 4px 6px;
  }
}

@media (min-width: 901px) and (hover: hover) and (pointer: fine) {
  .touch-controls:not(.force-touch) {
    display: none;
  }
}
