@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700;800;900&family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --gold: #d9ad52;
  --gold-light: #ffe5a0;
  --bg: #090a0e;
  --panel: #12131a;
  --muted: #92919a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, #252016 0%, transparent 48%),
    #08090d;
  color: #f5f0e5;
  font-family: Rajdhani, sans-serif;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}
button { font: inherit; cursor: pointer; }
.game-shell { width: min(1180px, 100%); }
.topbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.brand { display:flex; align-items:center; gap:13px; }
.brand-symbol {
  width:48px;height:48px;border:1px solid var(--gold);border-radius:50%;
  display:grid;place-items:center;color:var(--gold);font-size:27px;
  box-shadow:0 0 24px #d9ad5222;
}
.brand h1 { margin:0;font:800 21px Cinzel,serif;letter-spacing:2px; }
.brand h1 span,.overlay h2 span { color:var(--gold); }
.brand p { margin:3px 0 0;color:var(--muted);font-size:10px;letter-spacing:4px; }
.top-actions { display:flex;gap:9px; }
.icon-btn {
  width:42px;height:42px;background:#171820;border:1px solid #38343a;
  color:var(--gold);border-radius:9px;font-size:20px;
}
.hud {
  display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:12px;
}
.stat {
  padding:10px 15px;background:linear-gradient(120deg,#15161d,#101116);
  border:1px solid #292831;border-radius:9px;
}
.stat small,.result-grid small { display:block;color:var(--muted);font-size:10px;letter-spacing:2px; }
.stat strong { display:block;font:700 21px Cinzel,serif;margin-top:3px;color:var(--gold-light); }
.coins-stat strong { color:#f4d16e; }
.stage {
  position:relative;overflow:hidden;border:1px solid #54432b;border-radius:12px;
  background:#0b0d15;box-shadow:0 20px 65px #0009,0 0 30px #d9ad520b;
}
canvas { display:block;width:100%;height:auto;aspect-ratio:1000/440; }
.overlay {
  position:absolute;inset:0;display:grid;place-items:center;text-align:center;
  background:linear-gradient(90deg,#07080bd9,#090a0dcc,#07080bd9);
  backdrop-filter:blur(3px);padding:20px;
}
.hidden { display:none !important; }
.overlay-card { max-width:570px;width:100%; }
.eyebrow { color:var(--gold);letter-spacing:5px;font-size:11px;margin-bottom:14px; }
.overlay h2 { font:900 clamp(27px,5vw,48px) Cinzel,serif;letter-spacing:3px;margin:0 0 13px; }
.overlay-card p { color:#c0bdc0;font-size:17px;margin:0 auto 25px;max-width:440px; }
.primary-btn,.secondary-btn {
  display:block;margin:10px auto;padding:13px 30px;border-radius:5px;
  font:700 13px Cinzel,serif;letter-spacing:2px;min-width:220px;
}
.primary-btn {
  border:1px solid var(--gold-light);color:#17120a;
  background:linear-gradient(120deg,#a77b2e,#f3d58c,#b68a3d);
  box-shadow:0 0 25px #d9ad5230;
}
.secondary-btn { background:#171820;color:var(--gold);border:1px solid #66502e; }
.controls-hint { color:#aaa;font-size:11px;letter-spacing:1px;margin-top:22px; }
.ability-bar {
  display:flex;align-items:center;gap:20px;padding:14px 16px;margin-top:12px;
  background:var(--panel);border:1px solid #292831;border-radius:9px;
}
.ability { display:flex;align-items:center;gap:10px;flex:1;min-width:0; }
.ability-icon {
  width:38px;height:38px;display:grid;place-items:center;border:1px solid #8a692e;
  color:var(--gold-light);border-radius:8px;font-size:22px;background:#282015;
}
.power-icon { color:#fff0ad; }
.ability-info strong { display:block;font-size:12px;letter-spacing:1px; }
.ability-info small { color:var(--muted);font-size:11px; }
.ready,#powerStatus { color:#9ecb88;font-size:10px;letter-spacing:1px;white-space:nowrap; }
.cooldown-track { height:5px;background:#34313a;border-radius:5px;flex:1;max-width:65px;overflow:hidden; }
#powerFill { height:100%;width:100%;background:var(--gold);transition:width .1s; }
.settings-button { background:none;border:1px solid #49434a;color:#d5c49c;border-radius:6px;padding:9px 12px;white-space:nowrap;font-size:11px; }
.settings-card { max-width:390px; }
.setting-row { display:flex;justify-content:space-between;align-items:center;padding:13px;border-bottom:1px solid #39333a;color:#ddd;margin:5px 0;text-align:left; }
.setting-row input { accent-color:var(--gold);width:18px;height:18px; }
.result-grid { display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:24px 0; }
.result-grid div { background:#171820;padding:12px;border:1px solid #38333a;border-radius:7px; }
.result-grid strong { display:block;color:var(--gold-light);font:700 22px Cinzel,serif;margin-top:8px; }
.mobile-controls { display:none;gap:10px;margin-top:12px; }
.mobile-controls button {
  flex:1;padding:13px 5px;background:#211b13;border:1px solid #8a692e;
  color:var(--gold-light);border-radius:7px;font-weight:700;letter-spacing:1px;
  touch-action:none;
}
footer { display:flex;justify-content:space-between;color:#77737b;font-size:10px;letter-spacing:2px;padding:17px 3px; }
@media(max-width:650px) {
  body { padding:12px 8px; }
  .brand h1 { font-size:16px; }
  .brand-symbol { width:39px;height:39px; }
  .hud { gap:5px; }
  .stat { padding:8px 7px; }
  .stat strong { font-size:16px; }
  .stat small { font-size:8px;letter-spacing:1px; }
  .ability-bar { gap:9px;padding:10px 8px;flex-wrap:wrap; }
  .ability { gap:6px; }
  .ability-icon { width:30px;height:30px;font-size:17px; }
  .ability-info strong { font-size:9px; }
  .ability-info small,.ready,#powerStatus { font-size:9px; }
  .settings-button { font-size:9px;padding:8px; }
  .mobile-controls { display:flex; }
  footer { font-size:8px;letter-spacing:1px; }
  .controls-hint { font-size:9px;line-height:1.8; }
}


/* DEVICE ADAPTIVE GAME CONTROLS */
html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-controls {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-controls button {
  min-height: 48px;
  font-size: 13px;
}

.device-mobile .mobile-controls,
.device-tablet .mobile-controls,
.device-touch .mobile-controls {
  display: flex;
}

.device-desktop .mobile-controls {
  display: none;
}

.device-mobile .game-shell,
.device-tablet .game-shell {
  width: 100%;
  max-width: 1180px;
}

.device-mobile .stage {
  border-radius: 8px;
}

.device-mobile .ability-bar {
  flex-wrap: wrap;
}

@media (max-width: 420px) {
  body {
    padding: 8px 5px;
  }

  .mobile-controls {
    gap: 6px;
  }

  .mobile-controls button {
    min-height: 54px;
    font-size: 11px;
  }

  .brand p {
    letter-spacing: 2px;
  }

  footer span:last-child {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 550px) {
  body {
    padding: 5px 12px;
  }

  .topbar {
    margin-bottom: 5px;
  }

  .topbar .brand-symbol {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .hud {
    margin-bottom: 5px;
  }

  .stat {
    padding: 4px 10px;
  }

  .stage canvas {
    max-height: 55vh;
  }

  .ability-bar {
    margin-top: 5px;
    padding: 6px 10px;
  }

  .mobile-controls {
    margin-top: 5px;
  }

  footer {
    padding: 6px;
  }
}


/* ENEMY BATTLE SYSTEM */
.battle-hud {
  position:absolute;
  top:15px;
  left:50%;
  transform:translateX(-50%);
  z-index:5;
  width:min(410px,85%);
  padding:12px 18px;
  text-align:center;
  background:linear-gradient(120deg,#160f12ee,#21151aee);
  border:1px solid #b17b43;
  border-radius:9px;
  box-shadow:0 0 25px #e29b3630;
  pointer-events:none;
}
.battle-title {
  font-size:10px;
  letter-spacing:3px;
  color:#e4b45a;
}
.enemy-name {
  font:800 19px Cinzel,serif;
  color:#ffe1b0;
  margin:5px 0 8px;
}
.enemy-health-track {
  width:100%;
  height:10px;
  background:#4b2024;
  border:1px solid #9b5d43;
  border-radius:10px;
  overflow:hidden;
}
#enemyHealthFill {
  height:100%;
  width:100%;
  background:linear-gradient(90deg,#a51d2b,#f36a48);
  transition:width .15s;
}
.battle-instruction {
  font-size:9px;
  color:#d5bca6;
  letter-spacing:1px;
  margin-top:7px;
}
.player-health {
  color:#ff7777;
  letter-spacing:5px;
  margin-top:6px;
  font-size:17px;
}
.phase-ability .ability-icon {
  border-color:#8a68c0;
  color:#d4b3ff;
  background:#21182f;
}
#phaseFill {
  height:100%;
  width:100%;
  background:linear-gradient(90deg,#7954bd,#d8b2ff);
  transition:width .1s;
}
#phaseStatus {
  color:#c9a5ff;
  font-size:10px;
  white-space:nowrap;
}
#mobilePhase {
  border-color:#9670c5;
  color:#e0caff;
  background:#21182f;
}
@media(max-width:650px) {
  .phase-ability { flex-basis:45%; }
  .battle-hud { top:5px; padding:7px 10px; }
  .enemy-name { font-size:14px; }
  .battle-title,.battle-instruction { font-size:8px; }
}


/* ADVANCED COMBAT EFFECTS */
.combo-display {
  margin-top:6px;
  color:#ffe29a;
  font:700 15px Cinzel,serif;
  letter-spacing:2px;
  text-shadow:0 0 12px #ffb52d;
}
.enemy-warning {
  animation:enemyWarning .25s infinite alternate;
}
@keyframes enemyWarning {
  from { box-shadow:0 0 8px #e14a4a44; }
  to { box-shadow:0 0 28px #ff3b3b99; }
}
#mobileDodge {
  background:#242039;
  border-color:#9278d0;
  color:#dfcaff;
}
@media(max-width:650px) {
  .mobile-controls button { min-width:0; }
  .combo-display { font-size:12px; }
}
