:root {
  --bg: #06111d;
  --panel: rgba(7, 20, 34, 0.82);
  --panel-strong: rgba(5, 14, 25, 0.94);
  --panel-line: rgba(142, 214, 255, 0.18);
  --text: #eef8ff;
  --muted: #93aec1;
  --cyan: #48c8ff;
  --cyan-2: #1478bd;
  --orange: #ff9c18;
  --orange-2: #ff5a16;
  --danger: #ff4d45;
  --green: #53e09c;
  --shadow: 0 18px 48px rgba(0,0,0,.38);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { color: var(--text); user-select: none; -webkit-user-select: none; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.game-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 25% 15%, rgba(23, 106, 171, .3), transparent 34%),
    radial-gradient(circle at 80% 85%, rgba(8, 52, 83, .55), transparent 42%),
    #050d16;
}

.game-stage {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  min-width: 320px;
  overflow: hidden;
  isolation: isolate;
  background: #0b4064;
  box-shadow: 0 0 0 1px rgba(148, 223, 255, .12), 0 30px 80px rgba(0,0,0,.55);
}

.animated-background, #game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.animated-background { z-index: 0; }
#game-canvas { z-index: 1; cursor: crosshair; touch-action: none; }

.glass-panel {
  background:
    linear-gradient(135deg, rgba(19, 45, 68, .88), rgba(5, 15, 27, .82));
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
}

.top-hud {
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 26px);
  min-height: 70px;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: minmax(180px, .8fr) 68px minmax(360px, 1.7fr) 110px auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
}

.brand-block { display: flex; align-items: center; min-width: 0; gap: 7px; }
.brand-logo { display: block; width: min(200px, 15vw); height: auto; object-fit: contain; }
.prototype-badge {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
  white-space: nowrap;
  color: #7ee2ff;
  background: rgba(56, 183, 237, .12);
  border: 1px solid rgba(93, 203, 255, .24);
}

.turn-clock {
  height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 11px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.1);
}
.turn-clock strong { font-size: 27px; line-height: .95; text-shadow: 0 0 18px rgba(72,200,255,.5); }
.hud-label { font-size: 9px; letter-spacing: .12em; font-weight: 900; color: #95afc2; }

.turn-strip { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; overflow: hidden; }
.turn-avatar {
  position: relative;
  width: 58px;
  min-width: 42px;
  padding: 4px 5px;
  border-radius: 9px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.08);
  text-align: center;
  transition: transform .2s ease, border-color .2s ease, opacity .2s ease;
}
.turn-avatar.active { transform: translateY(-3px) scale(1.05); border-color: var(--orange); box-shadow: 0 0 20px rgba(255,140,20,.28); }
.turn-avatar.dead { opacity: .28; filter: grayscale(1); }
.turn-avatar i { display: block; width: 22px; height: 10px; border-radius: 4px 4px 6px 6px; margin: 0 auto 3px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.turn-avatar span { display: block; font-size: 8px; font-weight: 900; white-space: nowrap; }
.turn-avatar small { position: absolute; top: -6px; right: -4px; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; font-size: 8px; background: #101b25; border: 1px solid rgba(255,255,255,.16); }

.wind-box { text-align: center; }
.wind-line { display: flex; justify-content: center; align-items: center; gap: 8px; }
.wind-line strong { font-size: 18px; }
.wind-arrow { display: inline-block; color: var(--cyan); font-size: 22px; transition: transform .3s ease; text-shadow: 0 0 12px rgba(72,200,255,.7); }

.top-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px;
  background: rgba(0,0,0,.25); cursor: pointer; font-size: 16px;
  transition: transform .15s ease, background .15s ease;
}
.icon-btn:hover { transform: translateY(-2px); background: rgba(38,130,181,.28); }

.left-hud, .right-hud { position: absolute; z-index: 5; top: 94px; bottom: 124px; display: flex; flex-direction: column; pointer-events: none; }
.left-hud { left: 13px; width: min(250px, 18vw); justify-content: flex-end; }
.right-hud { right: 13px; width: min(245px, 17vw); gap: 8px; }
.left-hud > *, .right-hud > * { pointer-events: auto; }
.status-card, .mini-card, .order-card, .item-card { border-radius: var(--radius); padding: 10px; overflow: hidden; }
.status-card { max-height: 240px; display: flex; flex-direction: column; }
.mini-card { flex: 0 0 auto; }
.order-card { flex: 0 0 auto; }
.item-card { flex: 1 1 auto; min-height: 210px; }
.status-card h2, .mini-card h2, .order-card h2, .item-card h2 { margin: 0; font-size: 12px; letter-spacing: .02em; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.log-actions { display: flex; align-items: center; gap: 5px; }
.log-actions button { width: 24px; height: 24px; border: 1px solid rgba(112,205,245,.35); border-radius: 7px; background: #071b2a; cursor: pointer; }
.status-card.collapsed { padding-bottom: 8px; }
.status-card.collapsed .battle-log, .status-card.collapsed .chat-form { display: none; }
.round-label, .mode-chip, .selected-item-name { font-size: 8px; color: var(--cyan); padding: 3px 6px; border-radius: 999px; background: rgba(65,183,239,.12); border: 1px solid rgba(65,183,239,.18); white-space: nowrap; }

.battle-log { min-height: 110px; max-height: 150px; overflow-y: auto; scrollbar-width: thin; padding-right: 3px; font-size: 9px; line-height: 1.55; color: #bdcdd8; }
.battle-log p { position: relative; margin: 0 0 4px; padding-left: 15px; animation: log-in .25s ease; }
.battle-log p::before { position: absolute; left: 0; font-weight: 900; }
.battle-log p.system::before { content: "●"; }
.battle-log p.damage::before { content: "◆"; }
.battle-log p.info::before { content: "➜"; }
.battle-log p.chat::before { content: "▣"; }
.battle-log .system { color: #ffd45b; }
.battle-log .damage { color: #ff746e; }
.battle-log .info { color: #6ed9ff; }
.battle-log .chat { color: #d8e3ea; }
@keyframes log-in { from { opacity: 0; transform: translateY(4px); } }
.chat-form { display: grid; grid-template-columns: 1fr 30px; gap: 5px; margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(137,208,239,.16); }
.chat-form input { width: 100%; min-width: 0; height: 29px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; background: rgba(0,0,0,.3); color: white; padding: 0 8px; font-size: 9px; user-select: text; -webkit-user-select: text; }
.chat-form button { border: 0; border-radius: 8px; background: #176f9f; cursor: pointer; }

#mini-map { display: block; width: 100%; height: auto; border-radius: 8px; background: rgba(2,9,15,.6); border: 1px solid rgba(255,255,255,.08); }
.player-list { display: grid; gap: 5px; }
.player-row { display: grid; grid-template-columns: 22px 1fr 64px; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 7px; background: rgba(0,0,0,.23); border: 1px solid transparent; }
.player-row.active { border-color: rgba(255,158,26,.5); background: rgba(139,74,12,.22); }
.player-row.dead { opacity: .42; filter: grayscale(1); }
.player-index { width: 21px; height: 21px; display: grid; place-items: center; border-radius: 6px; font-size: 9px; font-weight: 900; }
.player-info { min-width: 0; }
.player-info strong { display: block; font-size: 9px; }
.player-hp-bar { height: 4px; border-radius: 99px; margin-top: 3px; overflow: hidden; background: rgba(255,255,255,.1); }
.player-hp-bar span { display: block; height: 100%; border-radius: inherit; transition: width .35s ease; }
.player-hp { text-align: right; font-size: 9px; font-weight: 900; }

.item-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.item-button { position: relative; min-width: 0; padding: 5px 2px 4px; border: 1px solid rgba(255,255,255,.08); border-radius: 9px; background: rgba(0,0,0,.22); cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.item-button:hover { transform: translateY(-2px); border-color: rgba(84,201,255,.42); }
.item-button.selected { border-color: var(--orange); background: rgba(146,75,7,.28); box-shadow: inset 0 0 15px rgba(255,151,16,.08); }
.item-button::before { content: attr(data-hotkey); position: absolute; top: 3px; left: 4px; min-width: 14px; height: 14px; display: grid; place-items: center; border-radius: 4px; background: #06131e; border: 1px solid rgba(255,255,255,.24); color: #fff; font-size: 7px; font-weight: 900; }
.item-button.selected::after { content: "✓"; position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: #142332; border: 2px solid var(--orange); font-size: 10px; font-weight: 1000; }
.item-button:disabled { opacity: .35; cursor: not-allowed; }
.item-button img { width: min(42px, 3.4vw); height: min(42px, 3.4vw); object-fit: contain; display: block; margin: 0 auto 2px; }
.item-button span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; font-weight: 800; }
.item-button small { position: absolute; top: 3px; right: 4px; min-width: 14px; padding: 1px 3px; border-radius: 99px; background: #08121d; color: #b9ccda; font-size: 7px; }

.bottom-hud {
  position: absolute; z-index: 6; left: 50%; bottom: 10px; transform: translateX(-50%);
  width: calc(100% - 26px); height: 102px; border-radius: var(--radius); padding: 9px 11px;
  display: grid; grid-template-columns: 140px 105px minmax(260px, 1fr) 105px 150px 110px; align-items: center; gap: 10px;
}
.active-player-card { align-self: stretch; display: flex; flex-direction: column; justify-content: center; padding: 0 12px; border-radius: 10px; background: rgba(0,0,0,.25); border-left: 3px solid var(--orange); }
.active-player-card strong { font-size: 16px; margin: 3px 0; }
.active-player-card span:last-child { font-size: 8px; color: #ffc764; letter-spacing: .08em; font-weight: 800; }
.angle-control { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.angle-control .hud-label { grid-column: 1 / -1; }
.angle-value strong { font-size: 29px; line-height: 1; }
.angle-value span { color: var(--cyan); }
.angle-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.angle-buttons button, .move-buttons button { width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; background: rgba(0,0,0,.25); cursor: pointer; }
.angle-buttons button:hover, .move-buttons button:hover { background: rgba(45,146,198,.28); }

.power-control { min-width: 0; }
.power-header { display: flex; justify-content: space-between; align-items: end; }
.power-header strong { font-size: 24px; line-height: 1; }
.power-track { position: relative; height: 25px; margin-top: 5px; border-radius: 999px; overflow: hidden; background: rgba(0,0,0,.48); border: 1px solid rgba(255,255,255,.12); cursor: pointer; }
.power-track::after { content: ""; position: absolute; inset: 3px; border-radius: inherit; background: repeating-linear-gradient(90deg, transparent 0 24%, rgba(255,255,255,.18) 24.5% 25%); pointer-events: none; }
.power-fill { height: 100%; width: 68%; border-radius: inherit; background: linear-gradient(90deg, #ff5a16, #ffbf21 70%, #fff47e); box-shadow: 0 0 18px rgba(255,136,16,.45); transition: width .05s linear; }
.power-fill.charging { animation: power-pulse .6s ease-in-out infinite alternate; }
@keyframes power-pulse { to { filter: brightness(1.25); } }
.power-marks { position: absolute; inset: 0 6px; display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 1px; font-size: 6px; color: rgba(255,255,255,.72); pointer-events: none; }
.power-help { margin: 3px 0 0; color: #7f9aae; font-size: 7px; text-align: center; }

.move-control { text-align: center; }
.move-buttons { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.move-energy { height: 4px; margin-top: 5px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.1); }
.move-energy span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #48c8ff, #61ecb3); }

.fire-button, .end-turn-button { border: 0; border-radius: 11px; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 9px 22px rgba(0,0,0,.28); transition: transform .12s ease, filter .12s ease; }
.fire-button:hover, .end-turn-button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.fire-button:active, .end-turn-button:active { transform: translateY(1px); }
.fire-button { height: 62px; display: flex; justify-content: center; align-items: center; gap: 8px; background: linear-gradient(135deg, #ffbd20, #ff6417 75%); color: #271306; }
.fire-button.charging { filter: brightness(1.2); box-shadow: 0 0 30px rgba(255,125,14,.5); }
.fire-icon { font-size: 25px; transform: rotate(-15deg); }
.fire-button strong { display: block; font-size: 18px; }
.fire-button small { display: block; font-size: 6px; letter-spacing: .08em; }
.end-turn-button { height: 52px; background: linear-gradient(135deg, #183a52, #0b2435); border: 1px solid rgba(81,190,239,.25); font-size: 12px; font-weight: 900; }
.end-turn-button small { display: block; margin-top: 3px; font-size: 6px; color: #8aa5b6; }
button:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.5); }

.mobile-controls { display: none; }
.toast { position: absolute; z-index: 12; left: 50%; top: 19%; transform: translate(-50%, -12px); padding: 9px 16px; border-radius: 99px; background: rgba(2,10,18,.88); border: 1px solid rgba(103,210,255,.25); box-shadow: 0 12px 28px rgba(0,0,0,.35); font-size: 11px; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.mytoolly-watermark { position: absolute; z-index: 3; right: 18px; bottom: 117px; font-size: 9px; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; color: rgba(255,255,255,.35); text-shadow: 0 1px 2px rgba(0,0,0,.5); pointer-events: none; }

.modal-layer { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(2,8,14,.66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .2s ease, visibility .2s ease; }
.modal-layer.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-card { position: relative; width: min(620px, 92%); border-radius: 21px; padding: 26px; text-align: center; background: linear-gradient(155deg, rgba(17,44,66,.97), rgba(4,13,23,.98)); border: 1px solid rgba(128,211,255,.2); box-shadow: 0 35px 90px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); }
.modal-logo { width: 260px; max-width: 75%; }
.start-card h1 { margin: 10px 0 6px; font-size: 27px; }
.start-card > p { max-width: 500px; margin: 0 auto 18px; color: #a8bdca; font-size: 12px; line-height: 1.7; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 auto 20px; }
.controls-grid > div { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px; border-radius: 10px; background: rgba(0,0,0,.24); color: #adc2d0; font-size: 10px; }
kbd { display: inline-flex; min-width: 25px; height: 23px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 5px; background: #101e2b; border: 1px solid #35526a; box-shadow: inset 0 -2px 0 rgba(0,0,0,.45); color: #eaf8ff; font-size: 9px; font-weight: 900; }
.primary-button, .secondary-button { min-width: 180px; min-height: 45px; padding: 0 20px; border-radius: 11px; font-weight: 900; cursor: pointer; }
.primary-button { border: 0; background: linear-gradient(135deg, #4bd0ff, #1777d2); box-shadow: 0 14px 28px rgba(17,117,201,.3); }
.secondary-button { border: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.28); margin-top: 8px; }
.result-card .secondary-button { margin-left: 8px; }
.secondary-button[hidden] { display: none; }
.start-card > small { display: block; margin-top: 13px; color: #6f8b9f; font-size: 8px; }
.mode-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 auto 14px; }
.stage-picker { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 10px; margin: 0 auto 12px; padding: 8px 10px; border-radius: 11px; background: rgba(2,12,21,.48); border: 1px solid rgba(126,196,228,.2); text-align: left; }
.stage-picker span { color: #83dfff; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.stage-picker select { width: 100%; min-height: 36px; padding: 0 10px; border: 1px solid rgba(98,197,237,.32); border-radius: 8px; background: #071a29; color: #eefaff; font-size: 11px; cursor: pointer; }
.stage-picker select:focus-visible { outline: 2px solid #59d6ff; outline-offset: 2px; }
.player-name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 auto 12px; }
.player-name-fields label { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 9px; padding: 8px 10px; border-radius: 11px; background: rgba(2,12,21,.48); border: 1px solid rgba(126,196,228,.2); text-align: left; }
.player-name-fields label[hidden] { display: none; }
.player-name-fields span { color: #83dfff; font-size: 8px; font-weight: 900; letter-spacing: .06em; }
.player-name-fields input { width: 100%; min-width: 0; min-height: 36px; padding: 0 10px; border: 1px solid rgba(98,197,237,.32); border-radius: 8px; background: #071a29; color: #eefaff; font-size: 11px; font-weight: 800; user-select: text; -webkit-user-select: text; }
.player-name-fields input:focus-visible { outline: 2px solid #59d6ff; outline-offset: 2px; }
.mode-option { display: grid; gap: 3px; min-height: 76px; padding: 11px; border: 1px solid rgba(126,196,228,.2); border-radius: 12px; background: rgba(2,12,21,.5); color: #91aebe; cursor: pointer; }
.mode-option strong { color: #f3fbff; font-size: 21px; letter-spacing: .04em; }
.mode-option span { font-size: 10px; font-weight: 800; }
.mode-option small { color: #65869a; font-size: 8px; }
.mode-option.selected { border-color: #48c8ff; background: linear-gradient(145deg, rgba(24,128,183,.32), rgba(8,38,58,.55)); box-shadow: 0 0 0 2px rgba(72,200,255,.1), inset 0 1px rgba(255,255,255,.08); }
.modal-close { position: absolute; right: 14px; top: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(0,0,0,.3); font-size: 22px; cursor: pointer; }
.help-card { text-align: left; }
.help-card > h2 { margin: 0 0 18px; }
.help-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help-columns > div { padding: 13px; border-radius: 12px; background: rgba(0,0,0,.22); }
.help-columns h3 { margin: 0 0 7px; color: #64d3ff; font-size: 12px; }
.help-columns p { margin: 0 0 15px; color: #b3c4cf; line-height: 1.7; font-size: 10px; }
.compact-card { width: min(380px, 90%); display: flex; flex-direction: column; align-items: center; }
.result-kicker { color: #ffc44b; font-size: 9px; font-weight: 900; letter-spacing: .2em; }
.result-card h2 { margin: 8px 0; font-size: 30px; }
.result-card p { color: #9cb3c2; font-size: 12px; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 17px 0; }
.result-stats div { padding: 12px; border-radius: 10px; background: rgba(0,0,0,.25); }
.result-stats strong { display: block; font-size: 20px; }
.result-stats span { color: #88a4b6; font-size: 8px; }

.loading-layer { z-index: 30; background: #07131e; }
.loading-card { width: min(430px, 80%); text-align: center; }
.loading-card img { width: 280px; max-width: 80%; }
.loading-bar { width: 100%; height: 6px; overflow: hidden; margin: 20px 0 8px; border-radius: 99px; background: rgba(255,255,255,.1); }
.loading-bar span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #38c8ff, #7dffa9); box-shadow: 0 0 16px rgba(63,202,255,.5); transition: width .2s ease; }
.loading-card p { color: #8aa7b9; font-size: 10px; }

@media (max-width: 1150px), (max-height: 720px) {
  .top-hud { grid-template-columns: 150px 54px 1fr 85px auto; min-height: 56px; top: 6px; }
  .brand-logo { width: 145px; }
  .prototype-badge { display: none; }
  .turn-clock { height: 43px; }
  .turn-clock strong { font-size: 21px; }
  .turn-avatar { width: 45px; }
  .top-actions .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .left-hud, .right-hud { top: 69px; bottom: 95px; }
  .bottom-hud { height: 82px; bottom: 6px; grid-template-columns: 105px 80px 1fr 80px 115px 85px; gap: 6px; padding: 6px 8px; }
  .active-player-card strong { font-size: 12px; }
  .angle-value strong { font-size: 23px; }
  .fire-button { height: 51px; }
  .fire-button strong { font-size: 14px; }
  .end-turn-button { height: 45px; font-size: 10px; }
  .mytoolly-watermark { bottom: 93px; }
  .item-button img { width: 30px; height: 30px; }
}

@media (max-width: 820px), (orientation: portrait) {
  body { overflow: auto; }
  .game-shell { min-height: 100dvh; }
  .game-stage { width: 100vw; height: 100dvh; }
  .animated-background, #game-canvas { object-fit: cover; }
  .top-hud { width: calc(100% - 12px); grid-template-columns: 1fr 48px 70px auto; padding: 5px 7px; }
  .brand-logo { width: 130px; }
  .turn-strip { display: none; }
  .wind-box { min-width: 60px; }
  .top-actions #settings-btn { display: none; }
  .left-hud { display: none; }
  .right-hud { top: 68px; right: 6px; bottom: auto; width: 132px; }
  .mini-card, .item-card { display: none; }
  .order-card { padding: 7px; }
  .player-row { grid-template-columns: 17px 1fr 30px; padding: 3px; }
  .player-index { width: 17px; height: 17px; }
  .bottom-hud { left: 6px; right: 6px; transform: none; width: auto; height: 76px; bottom: calc(65px + var(--safe-bottom)); grid-template-columns: 70px 65px 1fr 95px; }
  .active-player-card { display: none; }
  .move-control { display: none; }
  .end-turn-button { display: none; }
  .power-help { display: none; }
  .fire-button { height: 52px; }
  .mobile-controls { position: absolute; z-index: 7; left: 50%; bottom: calc(8px + var(--safe-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 52px); gap: 6px; }
  .mobile-controls button { width: 52px; height: 52px; border: 1px solid rgba(255,255,255,.15); border-radius: 14px; background: rgba(6,20,32,.88); box-shadow: 0 9px 20px rgba(0,0,0,.35); font-weight: 900; touch-action: none; }
  .mobile-controls .mobile-fire { background: linear-gradient(135deg,#ffbd20,#ff5b18); color: #281305; }
  .mytoolly-watermark { bottom: 148px; }
  .controls-grid, .help-columns { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* 2.0 HUD: keep the battlefield visible and reduce heavy panel chrome. */
.glass-panel {
  background: rgba(4, 16, 27, .72);
  border-color: rgba(136, 211, 243, .14);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
.top-hud { min-height: 60px; top: 8px; border-radius: 18px; grid-template-columns: minmax(150px,.7fr) 58px minmax(250px,1.5fr) 92px auto; }
.left-hud { width: 210px; bottom: 112px; opacity: .78; transition: opacity .2s ease; }
.left-hud:hover, .right-hud:hover { opacity: 1; }
.status-card { max-height: 172px; }
.battle-log { min-height: 68px; max-height: 92px; }
.right-hud { display: none; }
.mini-card { display: none; }
.weapon-dock { position: absolute; z-index: 7; left: 50%; bottom: 101px; transform: translateX(-50%); width: min(470px, 45vw); min-height: 0; padding: 6px 8px; border-radius: 14px; }
.weapon-dock .panel-title-row { display: none; }
.weapon-dock .item-grid { grid-template-columns: repeat(6, 1fr); }
.weapon-dock .item-button { padding: 3px 2px; }
.weapon-dock .item-button img { width: 28px; height: 28px; }
.bottom-hud { height: 88px; border-radius: 18px; grid-template-columns: 120px 82px 82px minmax(210px,1fr) 78px 124px 96px; }
.aim-wind { align-self: stretch; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 11px; background: rgba(5,22,34,.8); border: 1px solid rgba(72,200,255,.18); }
.aim-wind > div { display: flex; align-items: center; gap: 7px; }
.aim-wind strong { font-size: 27px; line-height: 1; }
#aim-wind-arrow { display: inline-block; color: #69d9ff; font-size: 24px; transition: transform .25s ease; }
.top-hud .wind-box { visibility: hidden; }
.active-player-card { background: rgba(0,0,0,.18); }
.fire-button { height: 56px; }
.end-confirm { display: none; font-size: 9px; line-height: 1.25; }
.end-turn-button.confirming { background: #54241f; border-color: #ff776b; }
.end-turn-button.confirming .end-default { display: none; }
.end-turn-button.confirming .end-confirm { display: block; }
.turn-avatar.active::after { content: "TURN"; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); padding: 1px 5px; border-radius: 99px; background: #fff; color: #17222b; font-size: 6px; font-weight: 1000; }

@media (max-width: 1100px), (max-height: 650px) {
  .left-hud { display: none; }
  .weapon-dock { bottom: 94px; width: min(430px, 58vw); }
  .bottom-hud { right: 7px; left: 7px; transform: none; width: auto; grid-template-columns: 82px 65px 68px minmax(140px,1fr) 62px 100px 74px; }
  .aim-wind strong { font-size: 21px; }
}

@media (max-width: 820px), (orientation: portrait) {
  html, body { overflow: hidden; }
  .game-shell { height: 100dvh; min-height: 0; }
  .game-stage { width: 100vw; height: 100dvh; min-width: 0; }
  #game-canvas { object-fit: contain; background: rgba(2,10,18,.45); }
  .animated-background { object-fit: cover; opacity: .72; }
  .weapon-dock { display: none; }
  .top-hud { grid-template-columns: 1fr 45px 64px auto; min-height: 52px; }
  .bottom-hud { grid-template-columns: 70px 1fr 88px; height: 68px; bottom: calc(64px + var(--safe-bottom)); }
  .angle-control { display: none; }
  .aim-wind { min-width: 66px; }
  .mode-selector { grid-template-columns: 1fr; }
  .player-name-fields { grid-template-columns: 1fr; }
  .modal-layer { padding: 10px; overflow-y: auto; align-items: start; }
  .modal-card { margin: auto; padding: 18px; }
  .controls-grid { display: none; }
  .mobile-controls button, .bottom-hud button { min-width: 44px; min-height: 44px; }
}
