:root {
  --ink: #1d1b33;
  --paper: #fff6e0;
  --paper2: #f1e3bf;
  --orange: #ff7a3c;
  --red: #ff4d5e;
  --yellow: #ffd23f;
  --green: #57d98a;
  --blue: #4aa3ff;
  --purple: #9a6bff;
  --night: #232044;
  --night2: #302c5e;
  --display: 'Lilita One', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body[data-screen='game'] { overflow: hidden; touch-action: none; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: 0.01em; }
p { margin: 0; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  font: 800 11px/1 var(--body);
  color: var(--paper);
  background: var(--ink);
  border-radius: 6px;
}

.screen { min-height: 100dvh; position: relative; }

.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 18px;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: 22px; }

.btn {
  font-family: var(--display);
  font-size: 16px;
  padding: 9px 16px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { background: #d9d2bd; color: #8a846f; box-shadow: 0 4px 0 #8a846f; border-color: #8a846f; }
.btn.big { font-size: 20px; padding: 12px 22px; border-radius: 16px; }
.btn.small { font-size: 13px; padding: 5px 10px; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); border-width: 2.5px; }
.btn.primary { background: var(--orange); color: var(--paper); text-shadow: 0 2px 0 var(--ink); }
.btn.ghost { background: transparent; color: var(--paper); border-color: var(--paper); box-shadow: none; }
.btn.ghost:active:not(:disabled) { transform: translateY(1px); }
.panel .btn.ghost { color: var(--ink); border-color: var(--ink); }

.ibtn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font: 800 17px/1 var(--body);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 0;
}
.ibtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ibtn.off { background: #b9b3a0; text-decoration: line-through; }

.link { background: none; border: 0; padding: 0; color: var(--paper); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

.field { display: grid; gap: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.field.inline { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
input, select {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 17px;
  font-weight: 800;
  outline: none;
  min-width: 0;
}
input:focus, select:focus { box-shadow: 0 0 0 4px rgba(255, 122, 60, 0.45); }
.msg { min-height: 20px; font-size: 14px; color: #5b5676; }
.msg.bad { color: #d12d43; }

#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 9px 16px;
  border-radius: 12px;
  border: 2px solid var(--paper);
  font-size: 14px;
  animation: pop 0.2s ease-out;
  transition: opacity 0.4s, transform 0.4s;
  max-width: 90vw;
}
.toast.bad { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }

#home { display: grid; place-items: center; overflow: hidden; padding: 24px 16px; }
#homeSky { position: absolute; inset: 0; width: 100%; height: 100%; }
.home-wrap { position: relative; width: min(440px, 100%); display: grid; gap: 14px; justify-items: center; }
.logo {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: clamp(56px, 15vw, 92px);
  color: var(--yellow);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 7px 0 var(--ink);
  transform: rotate(-3deg);
  line-height: 1;
}
.logo span:nth-child(odd) { transform: translateY(-4px); }
.logo .o, .logo .o2 {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--orange);
  border: 4px solid var(--ink);
  box-shadow: 0 7px 0 var(--ink), inset -0.08em -0.08em 0 rgba(0, 0, 0, 0.18), inset 0.1em 0.1em 0 rgba(255, 255, 255, 0.35);
  margin: 0 3px;
}
.logo .o { animation: lob 1.6s ease-in-out infinite; }
.logo .o2 { background: var(--red); }
@keyframes lob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }
.tag { color: var(--ink); font-size: 17px; font-weight: 900; background: var(--paper); padding: 5px 14px; border-radius: 999px; border: 3px solid var(--ink); }
.home-card { width: 100%; display: grid; gap: 14px; }
.or { display: flex; align-items: center; gap: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #6a6583; }
.or i { flex: 1; height: 3px; background: var(--paper2); border-radius: 2px; }
.joinrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
#codeInput { font-family: var(--display); font-size: 26px; letter-spacing: 0.3em; text-align: center; text-transform: uppercase; font-weight: 400; }
.home-foot { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; font-size: 13px; color: var(--ink); background: rgba(255, 246, 224, 0.8); padding: 6px 14px; border-radius: 999px; }
.home-foot .link { color: var(--ink); }

#lobby { background: radial-gradient(circle at 20% 0%, var(--night2), var(--night) 60%); padding: 16px clamp(12px, 3vw, 32px) 40px; }
.lobby-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-size: 30px; color: var(--yellow); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); transform: rotate(-2deg); }
.spacer { flex: 1; }
.codechip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  padding: 4px 12px 4px 10px;
}
.codechip small { font-size: 10px; letter-spacing: 0.1em; color: #6a6583; }
.codechip b { font-family: var(--display); font-weight: 400; font-size: 28px; letter-spacing: 0.16em; color: var(--orange); }
.codechip span { font-size: 12px; background: var(--ink); color: var(--paper); padding: 4px 8px; border-radius: 8px; }
.codechip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.lobby-grid { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 20px; max-width: 1240px; margin: 0 auto; align-items: start; }
.col-left { display: grid; gap: 20px; }

.seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; font-size: 13px; font-weight: 800; }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg button:disabled:not(.on) { color: #a09a86; }

.slots { display: grid; gap: 8px; }
.slot {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 3px solid var(--ink);
  border-left: 10px solid var(--c, var(--ink));
  border-radius: 14px;
  padding: 6px 10px 6px 6px;
  min-height: 62px;
}
.slot.me { background: #fffbe9; box-shadow: 0 0 0 3px var(--yellow); }
.slot.off { opacity: 0.55; }
.slot.empty { border-style: dashed; border-left-width: 3px; color: #8d8872; justify-content: space-between; padding-left: 14px; background: transparent; font-size: 14px; }
.slot .face { width: 46px; height: 46px; object-fit: contain; background: color-mix(in srgb, var(--c) 22%, #fff); border-radius: 10px; border: 2px solid var(--ink); }
.slot .who { flex: 1; min-width: 0; display: grid; }
.slot .who b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .who b small { color: #8d8872; font-size: 11px; }
.slot .who span { font-size: 12px; color: #6a6583; }
.chip { font-style: normal; font-size: 10px; letter-spacing: 0.06em; padding: 4px 7px; border-radius: 7px; background: #e6dfc8; white-space: nowrap; }
.chip.ready { background: var(--green); }
.chip.host { background: var(--yellow); }
.chip.bot { background: #cfd4e6; }
.chip.wait { background: #ffd9d0; }
.teamchip { font-size: 11px; font-weight: 900; border: 2.5px solid var(--ink); border-radius: 8px; padding: 3px 8px; background: var(--c); color: #fff; text-shadow: 0 1px 0 var(--ink); }
.teamchip:disabled { opacity: 0.85; }
.slot .ibtn { width: 28px; height: 28px; font-size: 13px; border-width: 2.5px; border-radius: 9px; box-shadow: 0 2px 0 var(--ink); }

.lobby-opts { margin-top: 14px; display: grid; gap: 6px; }
.mapdesc { font-size: 13px; color: #5b5676; min-height: 34px; }
.lobby-actions { margin-top: 10px; display: grid; gap: 8px; }

.chatpanel { display: grid; }
.chatlog { display: grid; align-content: start; gap: 3px; overflow-y: auto; font-size: 14px; font-weight: 700; }
.chatpanel .chatlog { height: 150px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; }
.chatlog .line { overflow-wrap: anywhere; }
.chatlog .line.sys { color: #7b7692; font-size: 12.5px; }
.chatpanel .chatlog .line b { text-shadow: 0 0 0 var(--ink); filter: brightness(0.78) saturate(1.3); }
.chatform { display: flex; gap: 8px; margin-top: 8px; }
.chatform input { flex: 1; font-size: 14px; padding: 8px 10px; }

.chargrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.chartile {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 1px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 4px 7px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.08s;
}
.chartile:hover { transform: translateY(-2px); }
.chartile img { width: 64px; height: 64px; object-fit: contain; }
.chartile b { font-family: var(--display); font-weight: 400; font-size: 16px; }
.chartile span { font-size: 11px; color: #6a6583; }
.chartile i { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; display: grid; place-items: center; background: var(--ink); color: var(--paper); border-radius: 50%; font: 800 11px var(--body); }
.chartile.view { background: color-mix(in srgb, var(--c) 20%, #fff); }
.chartile.picked { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px var(--yellow); }
.chartile.picked::after { content: 'YOU'; position: absolute; top: -9px; left: -6px; background: var(--orange); color: #fff; font: 800 10px var(--body); padding: 3px 6px; border-radius: 6px; border: 2px solid var(--ink); }

.chardetail { margin-top: 16px; display: grid; gap: 12px; }
.cd-head { display: flex; gap: 14px; align-items: center; }
.cd-head img { width: 104px; height: 104px; flex: none; background: color-mix(in srgb, var(--c) 26%, #fff); border: 3px solid var(--ink); border-radius: 18px; object-fit: contain; }
.cd-head h3 { font-size: 28px; }
.cd-head em { font-style: normal; font-size: 13px; color: var(--orange); text-transform: uppercase; letter-spacing: 0.05em; }
.cd-head p { font-size: 14px; color: #4a4566; margin-top: 4px; line-height: 1.4; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; }
.stat { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat b { font-size: 13px; min-width: 34px; text-align: right; text-transform: none; }
.sbar, .aimrange { height: 12px; background: #e6dfc8; border: 2.5px solid var(--ink); border-radius: 8px; overflow: hidden; position: relative; }
.sbar i { display: block; height: 100%; background: var(--orange); }
.aimrange i { position: absolute; top: 0; bottom: 0; background: var(--blue); }
.passive { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 12px; display: grid; gap: 2px; font-size: 13.5px; }
.passive b { color: var(--purple); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.shotlist { display: grid; gap: 6px; }
.shothead { display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #6a6583; padding: 0 4px; }
.shotrow { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 7px 12px 7px 9px; }
.shotrow div { display: grid; }
.shotrow b { font-size: 15px; }
.shotrow span { font-size: 13px; color: #4a4566; line-height: 1.35; }
.shotrow i { font-style: normal; font-size: 13px; color: #6a6583; }
.shotrow.ss { background: #fff4c9; }
.shotrow.ss kbd { background: var(--orange); }

#game { height: 100dvh; background: #000; user-select: none; -webkit-user-select: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#cv:active { cursor: grabbing; }

.hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 12px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.players { display: grid; gap: 6px; width: 214px; }
.pcard {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 8px;
  align-items: center;
  background: rgba(29, 27, 51, 0.82);
  border: 2.5px solid var(--ink);
  border-left: 7px solid var(--c);
  border-radius: 12px;
  padding: 4px 8px 4px 5px;
  color: var(--paper);
  transition: transform 0.2s, background 0.2s;
}
.pcard.active { background: var(--paper); color: var(--ink); transform: translateX(8px); box-shadow: 0 3px 0 var(--ink); }
.pcard.dead { opacity: 0.5; filter: grayscale(0.8); }
.pface { width: 38px; height: 38px; object-fit: contain; background: color-mix(in srgb, var(--c) 30%, #fff); border-radius: 8px; }
.pname { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 112px; }
.pname small { font-size: 9px; opacity: 0.7; }
.pcard.me .pname::after { content: ' ★'; color: var(--yellow); }
.bar { height: 7px; background: rgba(255, 255, 255, 0.18); border-radius: 4px; overflow: hidden; position: relative; margin-top: 2px; }
.pcard.active .bar { background: #d9d2bd; }
.bar i { display: block; height: 100%; border-radius: 4px; transition: width 0.3s; }
.bar.hp i { background: var(--green); }
.bar.hp u { position: absolute; left: 0; top: 0; height: 3px; background: #8fe3ff; }
.bar.ss { height: 4px; }
.bar.ss i { background: var(--yellow); }
.bar.ss i.full { background: var(--orange); animation: blink 0.7s infinite alternate; }
@keyframes blink { to { filter: brightness(1.6); } }
.psub { display: flex; gap: 4px; align-items: center; font-size: 10px; margin-top: 2px; min-height: 13px; }
.psub b { font-size: 11px; }
.st { font-style: normal; padding: 1px 4px; border-radius: 4px; background: #555a70; color: #fff; font-size: 9px; }
.st-burn { background: #e2661e; }
.st-poison { background: #7e3fe0; }
.st-freeze { background: #3ba7d6; }
.st-mark { background: #d12d43; }
.ptag { font-size: 10px; font-weight: 900; letter-spacing: 0.04em; opacity: 0.8; }
.pcard.active .ptag { background: var(--orange); color: #fff; padding: 2px 5px; border-radius: 5px; opacity: 1; }

.hud-center { display: flex; gap: 10px; align-items: center; position: absolute; left: 50%; transform: translateX(-50%); top: 10px; }
.wind {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  padding: 4px 12px 4px 5px;
}
.wind.gust { background: var(--yellow); animation: shake 0.4s infinite; }
@keyframes shake { 50% { transform: translateX(2px) rotate(1deg); } }
.windface { width: 44px; height: 44px; border-radius: 50%; background: #cfe8ff; border: 3px solid var(--ink); display: grid; place-items: center; }
.windarrow {
  width: 30px;
  height: 14px;
  background: var(--orange);
  clip-path: polygon(0 32%, 58% 32%, 58% 0, 100% 50%, 58% 100%, 58% 68%, 0 68%);
  transition: transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.windtxt { display: grid; justify-items: center; line-height: 1; }
.windtxt b { font-family: var(--display); font-weight: 400; font-size: 26px; }
.windtxt small { font-size: 9px; letter-spacing: 0.1em; }
.turnbox {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(29, 27, 51, 0.85);
  color: var(--paper);
  border: 3px solid var(--ink);
  border-bottom: 5px solid var(--c, var(--ink));
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 15px;
  white-space: nowrap;
}
.turnbox.mine { background: var(--orange); color: #fff; text-shadow: 0 2px 0 var(--ink); border-color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.turnbox b { font-family: var(--display); font-weight: 400; font-size: 24px; min-width: 26px; text-align: center; }
.turnbox b.low { color: var(--yellow); animation: blink 0.4s infinite alternate; }
.hud-right { display: flex; gap: 6px; }

.banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6) rotate(-3deg);
  font-family: var(--display);
  font-size: clamp(34px, 7vw, 64px);
  color: var(--yellow);
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
  white-space: nowrap;
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
.banner.warn { color: var(--red); }
.banner.mine { color: #fff; }

.shotcall {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 27, 51, 0.85);
  color: var(--paper);
  font-size: 15px;
  padding: 5px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.shotcall.show { animation: call 2.4s ease-out; }
@keyframes call { 0% { opacity: 0; transform: translateX(-50%) translateY(-6px); } 10%, 80% { opacity: 1; transform: translateX(-50%); } 100% { opacity: 0; } }

.netstate { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; padding: 6px 14px; border-radius: 10px; border: 3px solid var(--ink); }

.intro { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(29, 27, 51, 0.45); pointer-events: none; padding: 16px; }
.intro-card { text-align: center; min-width: min(420px, 90vw); max-width: 520px; animation: pop 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); }
.intro-card small { font-size: 11px; letter-spacing: 0.16em; color: var(--orange); }
.intro-card h2 { font-size: 44px; line-height: 1.05; margin: 2px 0 6px; }
.intro-card p { font-size: 15px; color: #4a4566; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.tags span { background: var(--ink); color: var(--paper); font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.count { font-family: var(--display); font-size: 54px; color: var(--orange); min-height: 60px; line-height: 60px; }

.gamechat { position: absolute; left: 12px; bottom: 132px; width: min(330px, 46vw); display: grid; gap: 6px; pointer-events: none; }
.gamechat .chatlog { max-height: 150px; overflow: hidden; color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 4px rgba(0, 0, 0, 0.8); font-size: 13.5px; justify-items: start; }
.gamechat .line { background: rgba(29, 27, 51, 0.55); padding: 2px 8px; border-radius: 8px; transition: opacity 0.6s; }
.gamechat .line.sys { color: #d6d2ee; }
.gamechat .line.old { opacity: 0; }
.gamechat.open .chatlog { overflow-y: auto; pointer-events: auto; }
.gamechat.open .line.old { opacity: 1; }
.gamechat .chatform { margin: 0; pointer-events: auto; }
.gamechat input { width: 100%; font-size: 13px; padding: 6px 10px; background: rgba(255, 246, 224, 0.55); border-width: 2.5px; border-radius: 10px; }
.gamechat input:focus { background: var(--paper); }
.gamechat input::placeholder { color: rgba(29, 27, 51, 0.75); }

.deck {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: 12px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 9px 12px;
  max-width: calc(100vw - 16px);
  transition: filter 0.2s, opacity 0.2s;
}
.deck.off { filter: saturate(0.5) brightness(0.95); }
.deck.off .deck-power, .deck.off .deck-aim, .deck.off .deck-move, .deck.off #btnSkip { opacity: 0.5; pointer-events: none; }
.deck.dead { opacity: 0.6; }
.deck.spectate { display: none; }
.deck > div { display: grid; align-content: center; justify-items: center; gap: 4px; }
.deck small { font-size: 9px; letter-spacing: 0.1em; color: #6a6583; }
.deck-id img { width: 50px; height: 50px; object-fit: contain; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; }
.deck-id b { font-family: var(--display); font-weight: 400; font-size: 13px; }
.pad {
  width: 34px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 9px;
  box-shadow: 0 2px 0 var(--ink);
  padding: 0;
  touch-action: none;
}
.pad:active { transform: translateY(2px); box-shadow: none; background: var(--yellow); }
.deck-aim { grid-template-rows: auto auto auto; }
.angle { display: grid; justify-items: center; line-height: 1; }
.angle b { font-family: var(--display); font-weight: 400; font-size: 28px; min-width: 52px; text-align: center; }
.angle b::after { content: '°'; font-size: 16px; vertical-align: top; }
.moverow { display: flex; gap: 5px; }
.stam { width: 74px; height: 9px; background: #e6dfc8; border: 2.5px solid var(--ink); border-radius: 6px; overflow: hidden; }
.stam i { display: block; height: 100%; background: var(--blue); }
.deck-power { min-width: clamp(150px, 24vw, 300px); }
.power { position: relative; width: 100%; height: 30px; background: #2b2946; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.power i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange) 60%, var(--red)); background-size: clamp(150px, 24vw, 300px) 100%; }
.power em { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; box-shadow: 0 0 0 1px var(--ink); transform: translateX(-1px); }
.power b { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #fff; font-family: var(--display); font-weight: 400; font-size: 16px; text-shadow: 0 1px 0 var(--ink); }
.ticks { position: absolute; inset: 0; display: flex; justify-content: space-evenly; pointer-events: none; }
.ticks u { width: 2px; background: rgba(255, 255, 255, 0.22); }
.btn.fire { width: 100%; background: var(--red); color: #fff; text-shadow: 0 2px 0 var(--ink); font-size: 15px; padding: 7px 10px; touch-action: none; }
.btn.fire kbd { margin-left: 6px; background: rgba(29, 27, 51, 0.6); }

.shots { display: flex; gap: 6px; }
.shot {
  position: relative;
  display: grid;
  gap: 1px;
  justify-items: start;
  width: 108px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 5px 8px 6px 30px;
  text-align: left;
}
.shot kbd { position: absolute; left: 5px; top: 6px; }
.shot .sname { font-size: 12.5px; font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.shot .sdmg { font-size: 11px; color: #6a6583; }
.shot.sel { background: var(--yellow); transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink); }
.shot.ss.sel { background: var(--orange); color: #fff; }
.shot.locked { opacity: 0.6; }
.shot.muted { opacity: 0.45; }
.ssbar { width: 100%; height: 7px; background: #e6dfc8; border: 2px solid var(--ink); border-radius: 5px; overflow: hidden; margin-top: 2px; }
.ssbar i { display: block; height: 100%; background: var(--orange); }
.shot.ss:not(.locked) .ssbar i { background: var(--red); animation: blink 0.6s infinite alternate; }
.activefx { display: flex; align-items: center; gap: 5px; font-size: 11px; background: var(--ink); color: var(--paper); padding: 2px 8px 2px 3px; border-radius: 999px; }
.activefx img { width: 18px; height: 18px; }
.items { display: flex; gap: 5px; }
.item {
  position: relative;
  width: 44px;
  height: 44px;
  background: color-mix(in srgb, var(--c, #ccc) 26%, #fff);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 0;
  display: grid;
  place-items: center;
}
.item img { width: 30px; height: 30px; }
.item kbd { position: absolute; top: -8px; left: -6px; min-width: 18px; height: 18px; font-size: 10px; }
.item.empty { background: transparent; border-style: dashed; box-shadow: none; opacity: 0.4; }
.item.used { opacity: 0.4; }
.item:not(.empty):not(.used):hover { transform: translateY(-2px); }

.tip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  display: grid;
  gap: 2px;
  pointer-events: none;
}
.tip b { font-family: var(--display); font-weight: 400; font-size: 16px; color: var(--yellow); }
.tip span { line-height: 1.35; }
.tip i { font-style: normal; font-size: 11px; opacity: 0.7; }

.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(29, 27, 51, 0.6); padding: 16px; overflow: auto; }
.results-card { width: min(560px, 100%); text-align: center; display: grid; gap: 10px; animation: pop 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); }
.results-card h2 { font-size: 44px; color: var(--orange); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.results-card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.results-card th { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #6a6583; padding: 4px; }
.results-card td { padding: 5px 4px; border-top: 2px solid var(--paper2); }
.results-card td img { width: 36px; height: 36px; object-fit: contain; display: block; }
.results-card td:nth-child(2) { text-align: left; }
.results-card td small { display: block; color: #6a6583; font-size: 11px; }
.results-card td b { filter: brightness(0.8) saturate(1.3); }
.results-card tr.won td { background: #fff4c9; }
.results-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.help-card { width: min(760px, 100%); position: relative; max-height: 92dvh; overflow: auto; }
.help-card h2 { font-size: 32px; margin-bottom: 10px; }
.help-card h3 { font-size: 18px; color: var(--orange); margin: 10px 0 2px; }
.help-card p { font-size: 14px; line-height: 1.45; color: #3d3958; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.keys { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 7px; font-size: 14px; }
.keys li { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.keys span { margin-left: 6px; color: #3d3958; }
.hint { margin-top: 10px; font-size: 13px !important; }
.close { position: absolute; top: 12px; right: 12px; }

@media (max-width: 980px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .deck-id { display: none !important; }
  .players { width: 168px; }
  .pname { max-width: 74px; }
}

@media (max-width: 820px), (max-height: 520px) {
  .players { display: flex; width: auto; gap: 5px; }
  .pcard { grid-template-columns: 34px; gap: 3px; padding: 3px; border-left-width: 2.5px; border-bottom: 5px solid var(--c); border-radius: 10px; }
  .pcard.active { transform: translateY(5px); }
  .pface { width: 34px; height: 34px; }
  .pname, .psub, .ptag, .bar.ss { display: none; }
  .bar.hp { margin-top: 0; height: 5px; }
  .hud-right { gap: 4px; }
  .hud-right .ibtn { width: 32px; height: 32px; font-size: 15px; }
  .btn.fire kbd { display: none; }
}

@media (max-width: 820px) {
  .deck { flex-wrap: wrap; justify-content: center; gap: 8px 10px; padding: 7px 8px; width: calc(100vw - 12px); bottom: 6px; }
  .deck-power { flex: 1 1 140px; min-width: 120px; }
  .shot { width: 96px; }
  .hud-center { top: 68px; left: 10px; transform: none; gap: 6px; align-items: flex-start; }
  .wind { transform: scale(0.82); transform-origin: left top; margin-right: -18px; }
  .turnbox { font-size: 12px; padding: 4px 9px; border-radius: 12px; }
  .turnbox b { font-size: 19px; min-width: 20px; }
  .shotcall { top: 118px; }
  .banner { top: 30%; }
  .help-grid { grid-template-columns: 1fr; gap: 6px; }
  .chargrid { gap: 7px; }
  .chartile img { width: 48px; height: 48px; }
  .stats { grid-template-columns: 1fr; }
  #btnZoomIn, #btnZoomOut { display: none; }
}

@media (max-width: 560px) {
  .deck > .deck-shots { flex: 1 1 100%; }
  .shots { width: 100%; }
  .shot { flex: 1; width: auto; min-width: 0; }
  .deck > .deck-items { flex: 1 1 100%; display: flex; justify-content: center; align-items: center; gap: 14px; }
  .cd-head img { width: 76px; height: 76px; }
  .gamechat { width: 62vw; }
  .lobby-head .btn.ghost { padding: 6px 10px; font-size: 13px; }
  .brand { font-size: 24px; }
}

@media (max-height: 520px) {
  .deck { flex-wrap: nowrap; width: auto; gap: 8px; padding: 5px 8px; bottom: 4px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
  .deck small { display: none; }
  .deck-power { flex: 0 1 150px; min-width: 110px; }
  .power { height: 22px; }
  .btn.fire { font-size: 13px; padding: 5px 8px; }
  .shot { width: 88px; }
  .shot .sdmg { display: none; }
  .item { width: 36px; height: 36px; }
  .item img { width: 24px; height: 24px; }
  .angle b { font-size: 20px; min-width: 40px; }
  .pad { height: 20px; }
  #btnSkip { padding: 2px 8px; font-size: 11px; }
  .gamechat { width: 240px; }
  .gamechat .chatlog { max-height: 56px; }
  .gamechat input { padding: 3px 8px; font-size: 12px; }
  .hud-center { top: 6px; }
  .wind { transform: scale(0.8); transform-origin: center top; }
  .turnbox { padding: 4px 10px; font-size: 13px; }
  .intro-card h2 { font-size: 30px; }
  .count { font-size: 36px; min-height: 40px; line-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo .o, .wind.gust, .bar.ss i.full, .turnbox b.low { animation: none; }
}

.deck .btn.ghost { color: var(--ink); border-color: var(--ink); opacity: 0.75; }
.deck .btn.ghost:hover { opacity: 1; }
