:root {
  --fire: #ff5916;
  --ice: #3be7ff;
  --gold: #ffd16b;
  --bg: #05070c;
  --card: #0b0e16f2;
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: #f4f7ff;
  font-family: "Segoe UI", "SF Pro Display", Inter, system-ui, sans-serif;
}

body { overscroll-behavior: none; }

button, canvas {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.ambient {
  position: fixed;
  width: 52vw;
  height: 52vw;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.ambient-fire {
  left: -18vw;
  bottom: -12vw;
  background: radial-gradient(circle, #ff3b00 0%, transparent 70%);
  opacity: 0.28;
}

.ambient-ice {
  right: -18vw;
  top: -12vw;
  background: radial-gradient(circle, #00c4ff 0%, transparent 70%);
  opacity: 0.26;
}

.grid-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
}

.cabinet {
  width: min(1180px, 96vw);
  padding: 18px 22px 10px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #0d111adf, #05070cf2);
  box-shadow: 0 0 80px #00c8ff12, 0 0 90px #ff3b0010, inset 0 0 42px #ffffff05;
}

.hud-top {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  margin-bottom: 10px;
}

.hud-top > div { display: flex; flex-direction: column; }
.align-right { align-items: flex-end; }

.hud-top span, .eyebrow {
  font-size: 11px;
  letter-spacing: 0.34em;
  color: #8aa0b8;
  font-weight: 800;
}

.hud-top strong {
  font-size: 25px;
  color: #fff;
  text-shadow: 0 0 12px #ff630088;
}

.brand { text-align: center; align-items: center; }

.brand h1 {
  margin: 0;
  font-size: clamp(16px, 2.2vw, 28px);
  letter-spacing: 0.18em;
  font-weight: 800;
}

.ice {
  color: #7af3ff;
  text-shadow: 0 0 16px #00d4ff, 0 0 32px #00a6ff66;
}

.fire {
  color: #ff7a32;
  text-shadow: 0 0 16px #ff3a00, 0 0 32px #ff4d0066;
}

.brand small {
  color: #c9d4e3;
  letter-spacing: 0.24em;
  font-size: 11px;
}

.game-layout {
  display: grid;
  grid-template-columns: 150px minmax(0, 672px) 150px;
  gap: 16px;
  justify-content: center;
  align-items: start;
}

.game-layout aside { display: flex; flex-direction: column; gap: 12px; }

.panel, .legend {
  border: 1px solid var(--line);
  background: #0a0d14cc;
  padding: 13px;
}

.panel span {
  display: block;
  color: #8aa0b8;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  font-size: 11px;
}

.panel > b {
  display: block;
  color: var(--gold);
  font-size: 13px;
}

.panel > b.awake {
  color: var(--ice);
  text-shadow: 0 0 9px #00cfff;
}

.life-orbs {
  color: #ff6b18 !important;
  letter-spacing: 5px;
  text-shadow: 0 0 8px #ff3b00;
}

body.skin-ice .life-orbs {
  color: #7af3ff !important;
  text-shadow: 0 0 8px #00cfff;
}

.meter {
  height: 8px;
  display: block;
  border: 1px solid #243044;
  padding: 1px;
}

.meter em {
  height: 100%;
  display: block;
  width: 0;
  background: linear-gradient(90deg, #ff3000, #ffcd4c);
  box-shadow: 0 0 10px #ff4b00;
}

.meter.blue em {
  background: linear-gradient(90deg, #079dc7, #80efff);
  box-shadow: 0 0 10px #00dcff;
}

.legend {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #7d8ea3;
}

.legend b { font-size: 10px; color: #ff7c42; }
body.skin-ice .legend b { color: #7af3ff; }
.legend small { font-size: 9px; }

.canvas-wrap { width: 100%; }

.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  box-shadow: 0 0 30px #00c8ff14, 0 0 30px #ff3d0014;
  touch-action: none;
  overflow: hidden;
}

.canvas-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.touch-hint {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #d7e6ff;
  background: #05070ccc;
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.touch-hint.show { opacity: 1; }

.cabinet footer {
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  color: #9aa8bc;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.cabinet footer > span { color: #5e6d82; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 40%, #0b1220e8, #05070cfa 72%);
}

.overlay.hidden { display: none; }

.intro-card {
  width: min(720px, 95vw);
  text-align: center;
  border: 1px solid var(--line);
  padding: 36px 40px 28px;
  background: linear-gradient(160deg, #101624f5, #070a10f7);
  box-shadow: 0 0 80px #00c8ff18, 0 0 80px #ff3d0014, inset 0 0 35px #ffffff06;
}

.eyebrow {
  margin: 0 0 10px;
  color: #8aa0b8;
}

.hero-title {
  font-size: clamp(28px, 6vw, 56px);
  line-height: 0.95;
  margin: 8px 0 6px;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.hero-title b {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 0.62em;
  letter-spacing: 0.28em;
  text-shadow: none;
  font-weight: 800;
}

.lead {
  max-width: 560px;
  margin: 16px auto 22px;
  color: #b7c4d6;
  line-height: 1.65;
  font-size: 14px;
}

.skin-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 0 auto 22px;
  max-width: 560px;
}

.skin-card {
  position: relative;
  text-align: left;
  border: 1px solid #2a3548;
  background: #0b1018;
  color: inherit;
  padding: 16px 16px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.skin-card .skin-icon {
  display: block;
  font-size: 22px;
  margin-bottom: 8px;
}

.skin-card strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.18em;
  margin-bottom: 6px;
}

.skin-card small {
  display: block;
  color: #8aa0b8;
  font-size: 11px;
  line-height: 1.4;
}

.skin-card .indicator {
  position: absolute;
  top: 16px;
  right: 14px;
  width: 10px;
  height: 10px;
  border: 2px solid #3a4a60;
  border-radius: 50%;
}

.skin-card[data-skin="ice"].selected {
  border-color: #3be7ff;
  box-shadow: 0 0 18px #00d4ff44, inset 0 0 18px #00d4ff14;
}

.skin-card[data-skin="fire"].selected {
  border-color: #ff6a22;
  box-shadow: 0 0 18px #ff3b0044, inset 0 0 18px #ff3b0014;
}

.skin-card.selected .indicator {
  border-color: transparent;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.skin-card[data-skin="ice"].selected .indicator { background: #3be7ff; color: #3be7ff; }
.skin-card[data-skin="fire"].selected .indicator { background: #ff6a22; color: #ff6a22; }

.skin-card, .start-btn, .pause-fab { touch-action: manipulation; }

.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(100%, 420px);
  margin: 4px auto 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, #19d7ff, #ff5a14);
  color: #fff;
  padding: 16px 34px;
  font: 800 15px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.22em;
  cursor: pointer;
  box-shadow: 0 0 28px #19d7ff55, 0 0 28px #ff5a1455;
  transition: transform 0.2s, filter 0.2s;
}

.start-btn:hover { transform: scale(1.03); filter: brightness(1.08); }

.play-tri {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #fff;
}

.keys {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #9aa8bc;
  letter-spacing: 0.12em;
  margin: 0;
}

kbd {
  display: inline-block;
  min-width: 22px;
  margin: 0 2px;
  padding: 2px 6px;
  border: 1px solid #3a4a60;
  border-radius: 4px;
  background: #121826;
  font: 700 10px/1.4 ui-monospace, monospace;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px auto 20px;
}

.stats div {
  border: 1px solid var(--line);
  background: #0b1018;
  padding: 10px;
}

.stats b { display: block; color: var(--gold); font-size: 20px; }
.stats small { color: #8aa0b8; font-size: 8px; letter-spacing: 0.12em; }

.hidden { display: none !important; }

.touch-pad {
  display: none;
  position: fixed;
  z-index: 16;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 6px;
  touch-action: none;
}

.dir-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dir-btn, .stick-base {
  border: 1px solid #2c5270;
  background: #0b1520e6;
  color: #9befff;
  box-shadow: inset 0 0 14px #00c8ff22, 0 0 12px #00c8ff22;
}

body.skin-fire .dir-btn,
body.skin-fire .stick-base {
  border-color: #8a3219;
  color: #ffb08a;
  box-shadow: inset 0 0 14px #ff3c001f, 0 0 12px #ff3c0022;
}

.dir-btn {
  width: 64px;
  height: 52px;
  margin: 0;
  font-size: 18px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: none;
}

.dir-btn:active, .dir-btn.held {
  background: #12344a;
  transform: scale(0.96);
}

.stick-base {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  touch-action: none;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e9feff, #3be7ff 55%, #0a6a88);
  box-shadow: 0 0 14px #3be7ffaa;
  pointer-events: none;
}

body.skin-fire .stick-knob {
  background: radial-gradient(circle at 35% 30%, #fff4d0, #ff6a22 55%, #8a1c00);
  box-shadow: 0 0 14px #ff6a22aa;
}

.mute-fab, .pause-fab {
  position: fixed;
  z-index: 21;
  top: max(10px, env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #0b1018e8;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.mute-fab { right: 12px; }
.mute-fab.muted { color: #8aa0b8; opacity: 0.55; }
.mute-fab.muted::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  border-top: 2px solid #ff6a22;
  transform: rotate(-28deg);
}

.pause-fab {
  display: none;
  right: 62px;
  font-size: 12px;
}

@media (max-width: 880px) {
  #app { display: block; padding: 8px 0 220px; overflow: visible; }
  .cabinet { width: 100%; padding: 10px 8px; border-left: 0; border-right: 0; }
  .game-layout { display: block; }
  .game-layout aside {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 7px 0;
  }
  .legend { display: none; }
  .canvas-wrap { width: min(100%, calc(100svh - 260px), 100vw); margin: 0 auto; }
  .hud-top { grid-template-columns: 1fr 1.6fr 1fr; }
  .hud-top strong { font-size: 17px; }
  .hud-top span { font-size: 8px; }
  .brand h1 { font-size: 13px; letter-spacing: 0.07em; }
  .brand small { font-size: 8px; }
  .panel { padding: 7px; }
  .panel span { font-size: 9px; margin-bottom: 4px; }
  .panel > b { font-size: 10px; }
  .cabinet footer { font-size: 8px; }
  .touch-pad { display: flex; }
  .touch-hint { display: block; }
  .pause-fab { display: grid; place-items: center; }
  .overlay { padding: 10px; }
  .intro-card { padding: 24px 16px 18px; }
  .skin-row { gap: 10px; }
  .skin-card { padding: 12px 10px; }
  .skin-card small { font-size: 10px; }
  .ambient { opacity: 0.18; }
}

@media (max-height: 700px) and (orientation: landscape) {
  #app { padding: 4px 140px 4px 8px; }
  .cabinet { width: min(1000px, 96vw); }
  .game-layout { grid-template-columns: 110px minmax(0, 68vh) 110px; }
  .canvas-wrap { width: min(68vh, 100%); }
  .panel { padding: 7px; }
  .hud-top { margin: 0; }
  .brand h1 { font-size: 16px; }
  .hud-top strong { font-size: 18px; }
  .cabinet footer { font-size: 9px; }
  .touch-pad {
    display: flex;
    left: auto;
    right: max(8px, env(safe-area-inset-right));
    bottom: 50%;
    transform: translateY(50%);
  }
  .pause-fab { display: grid; place-items: center; }
}
