@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=Inter:wght@400;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --ink: #e9f6ff;
  --muted: #7f95a8;
  --panel: #0a1726;
  --panel-2: #0e2132;
  --line: rgba(136, 191, 219, 0.18);
  --blue: #2bd4ff;
  --blue-2: #168cff;
  --orange: #ffae36;
  --orange-2: #ff5f2e;
  --green: #65f9ab;
  --danger: #ff4f60;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #030910; overscroll-behavior: none; }

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at 50% -20%, rgba(30, 105, 145, .18), transparent 45%),
    #030910;
  touch-action: manipulation;
  user-select: none;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1500px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto;
  background: #07111f;
  box-shadow: 0 0 80px #000;
  overflow: hidden;
}

.topbar {
  height: 64px;
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0c1c2c, #07131f);
  position: relative;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  transform: skew(-8deg); border: 2px solid var(--blue); color: var(--blue);
  font: 800 14px/1 Inter; box-shadow: inset 0 0 12px rgba(43,212,255,.16), 0 0 16px rgba(43,212,255,.12);
}
.brand div { display: flex; flex-direction: column; line-height: .9; }
.brand strong { font: 800 18px/1 "Barlow Condensed", sans-serif; letter-spacing: .08em; }
.brand div span { color: var(--blue); font: 700 11px/1.4 Inter; letter-spacing: .38em; }

.wind-card { display: flex; align-items: center; gap: 11px; color: var(--muted); font: 700 9px/1 Inter; letter-spacing: .18em; }
.wind-value { height: 34px; min-width: 84px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(2,11,18,.55); border: 1px solid var(--line); border-radius: 4px; }
.wind-value b { color: var(--blue); font-size: 21px; }
.wind-value strong { color: var(--ink); font-size: 12px; letter-spacing: .05em; }

.icon-button { justify-self: end; width: 38px; height: 38px; padding: 9px; border: 1px solid var(--line); border-radius: 4px; background: rgba(2,11,18,.55); cursor: pointer; }
.icon-button svg { width: 100%; fill: #9bb4c5; }
.icon-button.muted svg { fill: #4d6170; }

.battle-area { position: relative; min-height: 260px; background: #07111f; overflow: hidden; }
#gameCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

.player-card {
  position: absolute; z-index: 4; top: 16px; width: clamp(130px, 23vw, 250px); padding: 8px 10px;
  border: 1px solid var(--line); background: rgba(3, 13, 21, .76); backdrop-filter: blur(8px);
  transition: border-color .25s, opacity .25s, transform .25s;
}
.player-card::after { content: ""; position: absolute; inset: -1px; pointer-events: none; opacity: 0; box-shadow: 0 0 18px currentColor; transition: opacity .25s; }
.player-card.active::after { opacity: .22; }
.player-one { left: 16px; color: var(--blue); }
.player-two { right: 16px; color: var(--orange); }
.player-card:not(.active) { opacity: .65; transform: scale(.98); }
.player-title { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; }
.player-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.player-title b { color: var(--ink); font: 700 11px/1 "Barlow Condensed", sans-serif; letter-spacing: .12em; }
.player-title em { color: currentColor; font: 800 13px/1 Inter; font-style: normal; }
.health-track { height: 4px; margin-top: 7px; background: rgba(255,255,255,.1); overflow: hidden; }
.health-track i { display: block; height: 100%; width: 100%; background: currentColor; box-shadow: 0 0 8px currentColor; transition: width .5s ease; }

.turn-badge { position: absolute; z-index: 4; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; text-shadow: 0 2px 10px #000; pointer-events: none; }
.turn-badge span { color: var(--muted); font: 700 8px/1 Inter; letter-spacing: .28em; }
.turn-badge b { margin-top: 4px; font: 800 clamp(13px, 2vw, 18px)/1 "Barlow Condensed", sans-serif; letter-spacing: .12em; }

.canvas-hint { position: absolute; z-index: 4; left: 50%; bottom: 12px; transform: translateX(-50%); color: rgba(220,240,250,.7); background: rgba(2,9,14,.65); border: 1px solid rgba(255,255,255,.1); border-radius: 20px; padding: 7px 12px; font: 600 9px/1 Inter; letter-spacing: .08em; white-space: nowrap; transition: opacity .4s; pointer-events: none; }
.canvas-hint.hidden { opacity: 0; }

.result-overlay { position: absolute; z-index: 20; inset: 0; background: rgba(2,8,14,.72); backdrop-filter: blur(8px); place-items: center; }
.result-overlay:not([hidden]) { display: grid; }
.result-card { width: min(430px, calc(100% - 30px)); padding: 34px; text-align: center; background: linear-gradient(160deg, rgba(15,39,57,.96), rgba(5,15,25,.98)); border: 1px solid rgba(78,202,255,.35); box-shadow: 0 24px 90px #000; }
.result-card h1 { margin: 9px 0 8px; font: 800 clamp(27px, 5vw, 46px)/.95 "Barlow Condensed", sans-serif; text-transform: uppercase; }
.result-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--blue); font: 800 9px/1 Inter; letter-spacing: .26em; }

.control-deck { min-height: 126px; padding: 12px clamp(12px, 2.2vw, 28px); display: grid; grid-template-columns: minmax(330px, 1.2fr) minmax(260px, .8fr) minmax(160px, .48fr); align-items: center; gap: clamp(15px, 3vw, 38px); border-top: 1px solid rgba(126,190,220,.2); background: linear-gradient(180deg, #0d2031, #081521); box-shadow: 0 -12px 30px rgba(0,0,0,.25); z-index: 8; }
.section-label { display: block; margin-bottom: 7px; color: var(--muted); font: 700 8px/1 Inter; letter-spacing: .24em; }
.weapon-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.weapon { min-width: 0; height: 62px; padding: 7px 9px; display: flex; align-items: center; gap: 8px; text-align: left; border: 1px solid var(--line); background: rgba(4,13,22,.58); cursor: pointer; transition: .18s ease; }
.weapon:hover { border-color: rgba(106,208,255,.42); }
.weapon.active { border-color: var(--blue); background: linear-gradient(135deg, rgba(21,116,155,.25), rgba(7,20,31,.8)); box-shadow: inset 0 0 20px rgba(43,212,255,.08); }
.weapon:disabled { opacity: .35; cursor: not-allowed; }
.weapon-icon { flex: 0 0 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: #132b3e; color: var(--blue); border: 1px solid rgba(60,198,255,.28); font-weight: 800; }
.trident-icon { color: #8cf9bd; transform: rotate(90deg); }
.meteor-icon { color: var(--orange); }
.weapon span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.weapon b { color: #eaf7ff; font: 700 11px/1 "Barlow Condensed", sans-serif; letter-spacing: .1em; }
.weapon small { color: var(--muted); font: 600 8px/1 Inter; white-space: nowrap; }

.aim-controls { display: grid; gap: 11px; }
.range-control span { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.range-control b { color: var(--muted); font: 700 8px/1 Inter; letter-spacing: .2em; }
.range-control output { color: var(--blue); font: 800 13px/1 Inter; }
.power-control output { color: var(--orange); }
input[type="range"] { appearance: none; width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--blue) 0 var(--fill,50%), rgba(255,255,255,.12) var(--fill,50%)); }
.power-control input::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--orange) 0 var(--fill,50%), rgba(255,255,255,.12) var(--fill,50%)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #eaf8ff; border: 4px solid var(--blue-2); box-shadow: 0 0 11px rgba(43,212,255,.65); }
.power-control input::-webkit-slider-thumb { border-color: var(--orange-2); box-shadow: 0 0 11px rgba(255,135,44,.6); }

.fire-button, .primary-button { border: 0; cursor: pointer; background: linear-gradient(135deg, #ffbe42, #ff5e2d 78%); color: #1b0c03; box-shadow: 0 9px 26px rgba(255,92,42,.25), inset 0 1px rgba(255,255,255,.35); }
.fire-button { height: 72px; padding: 0 18px; display: flex; align-items: center; justify-content: center; gap: 12px; clip-path: polygon(8px 0,100% 0,100% calc(100% - 8px),calc(100% - 8px) 100%,0 100%,0 8px); transition: filter .15s, transform .12s; }
.fire-button:hover { filter: brightness(1.08); }
.fire-button:active { transform: scale(.97); }
.fire-button:disabled { filter: grayscale(.8); opacity: .48; cursor: not-allowed; }
.fire-button span:last-child { display: flex; flex-direction: column; align-items: flex-start; }
.fire-button b { font: 800 23px/1 "Barlow Condensed", sans-serif; letter-spacing: .08em; }
.fire-button small { font: 800 7px/1.6 Inter; letter-spacing: .1em; }
.fire-reticle { width: 29px; height: 29px; border: 2px solid #2a1406; border-radius: 50%; position: relative; }
.fire-reticle::before, .fire-reticle::after { content: ""; position: absolute; background: #2a1406; }
.fire-reticle::before { width: 37px; height: 2px; left: -6px; top: 12px; }
.fire-reticle::after { width: 2px; height: 37px; left: 12px; top: -6px; }

.footerbar { min-height: 36px; padding: 7px max(14px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #050d15; border-top: 1px solid rgba(255,255,255,.05); }
.footerbar > span { color: var(--muted); font-size: 9px; letter-spacing: .05em; }
.footerbar div { display: flex; gap: 14px; }
.footerbar button { padding: 0; border: 0; background: none; color: #8ea8b9; font: 700 8px/1 Inter; letter-spacing: .13em; cursor: pointer; }
.footerbar button:hover { color: var(--blue); }

dialog { width: min(510px, calc(100% - 28px)); color: var(--ink); background: linear-gradient(150deg, #10283b, #06111d); border: 1px solid rgba(75,196,244,.35); box-shadow: 0 28px 100px #000; padding: 30px; }
dialog::backdrop { background: rgba(0,5,10,.78); backdrop-filter: blur(6px); }
dialog h2 { margin: 8px 0 20px; font: 800 30px/1 "Barlow Condensed", sans-serif; text-transform: uppercase; }
dialog ol { margin: 0; padding-left: 22px; color: #acc0cc; font-size: 13px; line-height: 1.55; }
dialog li { margin-bottom: 10px; padding-left: 6px; }
dialog b { color: white; }
dialog p { color: var(--muted); font-size: 11px; }
.dialog-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; color: #8ea4b3; font-size: 28px; cursor: pointer; }
.primary-button { padding: 13px 24px; margin-top: 8px; font: 800 12px/1 Inter; letter-spacing: .12em; }

@media (max-width: 820px) {
  .app-shell { grid-template-rows: auto minmax(250px, 1fr) auto auto; }
  .topbar { height: 55px; }
  .control-deck { min-height: 186px; grid-template-columns: 1fr 1fr; gap: 10px 18px; padding: 10px 12px; }
  .weapon-section { grid-column: 1 / -1; }
  .weapon { height: 50px; }
  .weapon-icon { flex-basis: 27px; height: 27px; }
  .fire-button { height: 66px; }
  .player-card { top: 10px; }
  .turn-badge { top: 12px; }
}

@media (max-width: 520px) {
  .brand { min-width: auto; }
  .brand strong { font-size: 15px; }
  .brand-mark { width: 31px; height: 31px; }
  .topbar { grid-template-columns: 1fr auto auto; gap: 9px; }
  .wind-card > span { display: none; }
  .wind-value { min-width: 67px; padding: 0 8px; }
  .player-card { width: 125px; padding: 7px; }
  .player-one { left: 7px; }
  .player-two { right: 7px; }
  .player-title b { font-size: 9px; }
  .turn-badge { top: 47px; }
  .weapon { padding: 6px; justify-content: center; }
  .weapon span:last-child { display: none; }
  .weapon-icon { flex-basis: 30px; height: 30px; }
  .footerbar > span { display: none; }
  .footerbar { justify-content: center; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app-shell { grid-template-rows: 48px minmax(205px, 1fr) 103px 28px; }
  .topbar { height: 48px; }
  .control-deck { min-height: 103px; grid-template-columns: 1.2fr .9fr .48fr; padding-block: 7px; }
  .weapon-section { grid-column: auto; }
  .weapon { height: 52px; }
  .fire-button { height: 62px; }
  .footerbar { min-height: 28px; padding-block: 4px; }
}
