:root {
  --ink: #4d5170; --soft: #7d82a3; --paper: #fffaf3; --mint: #9ad7cf; --mint-d: #6fb7b4; --pink: #f6aaa6; --pink-d: #e08b95;
  --butter: #ffe7a3; --lav: #d9d3f5; --sky: #cfe9f7; --line: rgba(77, 81, 112, 0.18);
  --ctrl-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* HUD */
#hud { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 8px; right: 8px; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; padding-right: 92px; }
.card { background: rgba(255, 250, 243, 0.86); border-radius: 14px; padding: 6px 10px 7px; min-width: 0; flex: 1 1 0; max-width: 260px; box-shadow: 0 2px 0 var(--line); }
.card.right { text-align: right; margin-left: auto; }
.card .nm { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 11px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { position: relative; height: 10px; border-radius: 6px; background: #ece6f2; margin: 4px 0 2px; overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 6px; transition: width .35s; }
.bar .hp { background: var(--mint); }
#card1 .bar .hp { background: var(--pink); }
#card1 .bar i { left: auto; right: 0; }
.bar .sh { background: rgba(160, 200, 255, 0.85); }
.card.active { outline: 3px solid var(--butter); }
.mid { flex: 0 0 auto; text-align: center; background: rgba(255, 250, 243, 0.86); border-radius: 14px; padding: 5px 12px; box-shadow: 0 2px 0 var(--line); }
#level { font-size: 11px; font-weight: 800; color: var(--soft); letter-spacing: .04em; text-transform: uppercase; }
#wind { font-weight: 800; font-size: 15px; white-space: nowrap; }
#wind .arrow { display: inline-block; margin-right: 4px; color: #8fb8e8; }

#corner { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: 8px; display: flex; gap: 6px; z-index: 30; }
.round { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 250, 243, 0.9); box-shadow: 0 2px 0 var(--line); font-size: 18px; display: grid; place-items: center; }

#banner { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(.9); font-size: clamp(20px, 4.5vw, 34px); font-weight: 900; color: var(--ink);
  background: rgba(255, 250, 243, 0.92); padding: 8px 22px; border-radius: 999px; box-shadow: 0 3px 0 var(--line); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; z-index: 20; }
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* controls */
#controls { position: fixed; left: 0; right: 0; bottom: 0; padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: flex; gap: 8px; justify-content: center; align-items: stretch; background: linear-gradient(rgba(255, 250, 243, 0), rgba(255, 250, 243, .7) 30%); }
#controls.off .grp, #controls.off .weapon, #controls.off .fire { opacity: .45; pointer-events: none; }
.grp { display: flex; align-items: center; background: var(--paper); border-radius: 16px; box-shadow: 0 3px 0 var(--line); overflow: hidden; }
.grp button { width: 46px; height: 48px; font-size: 22px; font-weight: 800; background: transparent; }
.grp button:active { background: var(--lav); }
.lbl { min-width: 54px; text-align: center; line-height: 1; }
.lbl b { display: block; font-size: 18px; }
.lbl small, .weapon small { font-size: 10px; color: var(--soft); text-transform: uppercase; letter-spacing: .05em; }
.weapon { background: var(--butter); border-radius: 16px; box-shadow: 0 3px 0 var(--line); padding: 4px 12px; min-width: 112px; line-height: 1.1; }
.weapon b { display: block; font-size: 15px; }
.fire { background: var(--pink); color: #fff; font-weight: 900; font-size: 20px; letter-spacing: .06em; border-radius: 16px; box-shadow: 0 3px 0 var(--pink-d); padding: 0 22px; min-width: 96px; }
.fire:active, .weapon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }

/* portrait phones: two rows */
@media (max-width: 640px) and (orientation: portrait) {
  #controls { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
  #controls .grp { grid-column: span 2; justify-content: space-between; min-width: 0; }
  #controls .grp button { width: 34px; flex: 0 0 34px; }
  .lbl { min-width: 0; flex: 1; }
  .lbl b { font-size: 16px; }
  .weapon { grid-column: span 3; min-width: 0; }
  .fire { grid-column: span 3; height: 50px; min-width: 0; }
  #hud { padding-right: 0; top: calc(env(safe-area-inset-top) + 56px); }
  .card .sub { display: none; }
}
/* short landscape phones: smaller everything */
@media (max-height: 460px) and (orientation: landscape) {
  #controls { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); gap: 6px; }
  .grp button { width: 38px; height: 40px; font-size: 18px; }
  .lbl b { font-size: 15px; }
  .weapon { min-width: 96px; }
  .fire { font-size: 17px; min-width: 80px; }
  #hud { top: calc(env(safe-area-inset-top) + 4px); }
  #corner { top: calc(env(safe-area-inset-top) + 4px); }
  .card { padding: 3px 8px 4px; }
  .card .sub { display: none; }
  .round { width: 34px; height: 34px; font-size: 15px; }
}

/* overlay screens */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 25; overflow-y: auto; }
.screen:empty { display: none; }
.screen.dim { background: rgba(207, 233, 247, 0.55); backdrop-filter: blur(3px); }
.panel { background: var(--paper); border-radius: 26px; padding: 22px 22px 20px; box-shadow: 0 6px 0 var(--line), 0 20px 50px rgba(77, 81, 112, .15); width: min(440px, 100%); text-align: center; }
.panel.wide { width: min(760px, 100%); }
h1 { margin: 0 0 2px; font-size: clamp(34px, 8vw, 54px); font-weight: 900; letter-spacing: -.01em; color: var(--ink); line-height: 1; }
h1 span { color: var(--pink-d); }
h2 { margin: 0 0 10px; font-size: 24px; font-weight: 900; }
.tag { color: var(--soft); margin: 4px 0 16px; font-size: 15px; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 16px; background: var(--mint); color: #fff; font-weight: 900; font-size: 18px; box-shadow: 0 4px 0 var(--mint-d); margin-top: 10px; }
.btn.pink { background: var(--pink); box-shadow: 0 4px 0 var(--pink-d); }
.btn.plain { background: #efeaf6; color: var(--ink); box-shadow: 0 4px 0 #d9d2e8; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.seg { display: flex; gap: 6px; background: #efeaf6; padding: 4px; border-radius: 14px; margin-top: 10px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 10px; background: transparent; font-weight: 800; color: var(--soft); text-transform: capitalize; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--line); }
.best { margin-top: 14px; font-size: 13px; color: var(--soft); }
.best b { color: var(--ink); }
.hero { display: block; margin: 0 auto 6px; width: min(260px, 70%); image-rendering: auto; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.up { background: #fff; border-radius: 18px; padding: 14px 10px; box-shadow: 0 4px 0 var(--line); text-align: center; border: 2px solid transparent; }
.up:hover, .up:focus { border-color: var(--butter); }
.up:active { transform: translateY(3px); }
.up .ic { font-size: 34px; line-height: 1.2; }
.up b { display: block; font-size: 16px; margin: 4px 0; }
.up p { margin: 0; font-size: 13px; color: var(--soft); line-height: 1.3; }
.up .lv { font-size: 11px; color: var(--mint-d); font-weight: 800; margin-top: 6px; }
@media (max-width: 560px) { .cards { grid-template-columns: 1fr; } .up { display: grid; grid-template-columns: 48px 1fr; text-align: left; align-items: center; gap: 0 10px; padding: 10px; } .up .ic { grid-row: span 3; text-align: center; } }
@media (max-height: 460px) and (orientation: landscape) {
  .panel.title { width: min(720px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; }
  .panel.title .hero { width: 100%; max-width: 240px; }
  .panel.title h1 { font-size: 40px; }
  .panel.title .btn { padding: 11px; font-size: 16px; margin-top: 8px; }
  .panel.title .seg { margin-top: 8px; }
  .panel.title .seg button { padding: 7px 4px; }
  .panel.title .best { margin-top: 8px; }
  .panel.title .tag { margin-bottom: 0; }
}
@media (max-height: 460px) { .panel { padding: 14px 16px; } .up .ic { font-size: 26px; } .up p { font-size: 12px; } h2 { margin-bottom: 4px; } }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.pick { background: #fff; border-radius: 16px; padding: 8px; box-shadow: 0 3px 0 var(--line); }
.pick img { width: 100%; max-width: 150px; }
.pick .nm { font-weight: 800; }
.pick .arrows { display: flex; justify-content: space-between; align-items: center; }
.pick .arrows button { background: #efeaf6; border-radius: 10px; width: 36px; height: 32px; font-weight: 900; }
.stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 4px; font-size: 13px; color: var(--soft); }
.stats b { color: var(--ink); font-size: 16px; display: block; }
.weapons { display: grid; gap: 8px; margin-top: 6px; }
.weapons button { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 3px 0 var(--line); font-weight: 800; text-align: left; }
.weapons button.on { outline: 3px solid var(--butter); }
.weapons small { color: var(--soft); font-weight: 600; display: block; font-size: 12px; }
.update { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); background: var(--paper); padding: 8px 14px; border-radius: 12px; font-size: 13px; box-shadow: 0 3px 0 var(--line); z-index: 40; }
