:root {
  color-scheme: dark;
  --night: #080f19;
  --navy: #101e2c;
  --panel: #122332;
  --line: #314455;
  --text: #f2f4ef;
  --muted: #a4b8c6;
  --mint: #79dfc9;
  --mint-deep: #143d39;
  --gold: #e7bc78;
  --radius: 16px;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] { display: none !important; }
html { min-width: 280px; scrollbar-gutter: stable; }
body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 8% 0%, #1e3442 0, transparent 34rem), var(--night);
  color: var(--text);
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

button, input, select { font: inherit; }
button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .54rem .78rem;
  background: #1b2b3a;
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
button:enabled:hover { background-color: #25394a; border-color: #738698; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #f6cb82;
  outline-offset: 3px;
}
a { color: var(--mint); text-underline-offset: .22em; }
button.primary, .primary {
  border-color: var(--mint);
  background: var(--mint);
  color: #0c2927;
  font-weight: 750;
}
button.primary:enabled:hover { background: #9aefda; border-color: #a9ffe6; }
button.secondary { background-color: #182b3b; }
button.danger { border-color: #a05d61; color: #ffd1c7; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.32; text-wrap: balance; }
.muted { color: var(--muted); }
.eyebrow {
  color: var(--mint);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .12em;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 78px;
  padding: .9rem max(1rem, calc((100% - 1480px) / 2));
  border-bottom: 1px solid #405667;
  background: #10202ce8;
}
.brand, .tools, .stats, .statusbar, .playerbar, .phasebar {
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand { gap: .8rem; }
.brand h1, h1.brand { font-size: clamp(1.15rem, 2vw, 1.65rem); font-weight: 800; letter-spacing: -.055em; }
.brand small, .brand .eyebrow { display: block; }
.brand img { width: 40px; height: 40px; object-fit: cover; border-radius: 9px; }
.tools, .stats { flex-wrap: wrap; }
.tools { justify-content: flex-end; }
.tools button, .tools a { font-size: .83rem; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: clamp(12px, 1.5vw, 24px);
  width: 100%;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 28px) clamp(12px, 1.5vw, 20px) 2rem;
}
.table, .console, .hand-area, .lane { min-width: 0; }
.statusbar {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  margin-bottom: .7rem;
}
.statusbar h2, .statusbar strong { font-size: 1.05rem; }
.phasebar {
  gap: .2rem;
  flex-wrap: wrap;
  overflow: hidden;
}
.phase {
  padding: .28rem .52rem;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #a9bac6;
  font-size: .75rem;
  font-weight: 650;
}
.phase.active { color: #a3f0dd; border-color: #38766c; background: #173c38; }
.chip, .tag, .counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  min-height: 25px;
  padding: .18rem .52rem;
  border: 1px solid #415362;
  border-radius: 6px;
  background-color: #132432;
  color: #e3eceb;
  vertical-align: middle;
  font-size: .75rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.counter strong, .chip strong { font-size: .86rem; }
.mat {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #536272;
  border-radius: var(--radius);
  padding: .7rem clamp(.6rem, 1.5vw, 1.3rem);
  background-color: #142635;
  background-image:
    radial-gradient(ellipse at 50% 53%, #34515a75, transparent 65%),
    linear-gradient(180deg, #4d3c2a24 0%, transparent 45%, #14443e38 100%),
    repeating-linear-gradient(0deg, transparent 0 30px, #cadbdc07 30px 31px),
    repeating-linear-gradient(90deg, transparent 0 30px, #cadbdc07 30px 31px);
  box-shadow: inset 0 0 0 4px #0d1c274d, 0 8px 22px #0003;
}
.playerbar {
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 46px;
  gap: .4rem .65rem;
  padding: .32rem 0;
}
.playerbar > div, .playerbar .stats { min-width: 0; }
.playerbar strong, .playerbar h3 { font-size: .96rem; }
.playerbar .stats { justify-content: flex-end; }
.playerbar img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.playerbar:first-of-type, .playerbar.opponent { color: var(--gold); }
.playerbar:last-of-type, .playerbar.mine { color: var(--mint); }
.lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.1vw, 16px);
  align-items: stretch;
}
.lane {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: .45rem .25rem;
  border: 1px solid #8fa5ae33;
  border-radius: 10px;
  background: #0916222b;
}
.lane > small { font-size: .66rem; color: var(--muted); }
.unit, .empty {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: stretch;
  width: min(100%, clamp(92px, 12vw, 158px));
  height: clamp(128px, 19.5vh, 185px);
  overflow: hidden;
  padding: 0;
  border-radius: 7px;
}
.empty {
  place-content: center;
  border: 1px dashed #7594a06b;
  background: linear-gradient(145deg, #233a4794, #1424307d);
  color: #b3c4cd;
  font-size: .78rem;
  line-height: 1.3;
  text-align: center;
}
.empty:disabled { opacity: .78; }
.unit {
  border: 1px solid #b8a27a;
  background-color: #0e2230;
  background-size: cover;
  background-position: center 26%;
  box-shadow: 0 4px 10px #06111e99;
}
.unit img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 27%;
}
.unit .caption {
  z-index: 1;
  width: 100%;
  padding: 1.15rem .45rem .4rem;
  background: linear-gradient(0deg, #0a1825 0%, #0a1825ed 62%, #0a182500);
  color: #f8f7ef;
  text-align: left;
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.35;
}
.unit .caption b, .unit .caption strong { display: block; font-size: .9rem; }
.unit .caption small, .unit .caption em { color: #deebe9; font-size: .67rem; font-style: normal; }
.unit .equips {
  position: absolute;
  z-index: 2;
  top: .28rem;
  right: .25rem;
  max-width: calc(100% - .5rem);
  padding: .1rem .3rem;
  border-radius: 5px;
  background: #122d33ed;
  color: #d9fcf1;
  font-size: .66rem;
  line-height: 1.35;
}
.equips:empty { display: none; }
.legal, .lane.legal > .empty {
  border-color: #6fd5bc;
  box-shadow: inset 0 0 0 1px #72dac457, 0 0 0 1px #6dd0b83d;
}
.chosen, button[aria-pressed="true"] {
  border-color: #f6cb82;
  outline: 2px solid #efc27d;
  outline-offset: 2px;
}
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 22px;
  color: #b7cad0;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .06em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #62798133, #a8b8b577);
}
.divider::after { transform: scaleX(-1); }
.hand-area {
  margin-top: .85rem;
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #10202d;
}
.hand-area > h2, .hand-area > h3, .hand-area header { margin-bottom: .45rem; font-size: .98rem; }
.hand {
  display: flex;
  align-items: stretch;
  gap: .55rem;
  overflow-x: auto;
  scrollbar-color: #53757d #0d1d29;
  scrollbar-width: thin;
  padding: .3rem .18rem .55rem;
  scroll-snap-type: x proximity;
}
.hand-card {
  position: relative;
  display: flex;
  flex: 0 0 clamp(90px, 8.3vw, 122px);
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  padding: 0;
  border-radius: 7px;
  background: #132532;
  text-align: left;
  scroll-snap-align: start;
}
.hand-card img { width: 100%; height: clamp(85px, 12.5vh, 118px); object-fit: cover; object-position: center 22%; }
.hand-card b, .hand-card strong { padding: .32rem .4rem .05rem; font-size: .78rem; line-height: 1.28; }
.hand-card small { padding: .04rem .4rem .35rem; color: #bfced6; font-size: .68rem; }
.console {
  display: grid;
  align-content: start;
  gap: .85rem;
}
.console > section, .guide, .welcome {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(150deg, #1a2b39, #11202c 76%);
}
.console > section, .guide { padding: 1rem; }
.console > section:first-child { border-top: 3px solid #70c7b3; }
.console section h2 { margin-bottom: .55rem; font-size: 1.19rem; }
.console section h3 { margin-bottom: .45rem; font-size: 1rem; }
.console section p { color: #cbd7dd; font-size: .88rem; line-height: 1.65; }
.console .guide, .console section .guide { color: #bfeadf; background: #18332f; }
.choice-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .4rem;
  margin-top: .7rem;
}
.choice-list button {
  min-height: 41px;
  padding: .5rem .68rem;
  text-align: left;
  font-size: .84rem;
  line-height: 1.45;
}
.choice-list button small { display: block; margin-top: .1rem; font-size: .71rem; }
.choice-list button.primary { font-weight: 750; }
.choice-list button.secondary { color: #dce8ea; }
.log {
  max-height: 22rem;
  overflow-y: auto;
  scrollbar-width: thin;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
}
.log li { padding: .44rem 0; border-bottom: 1px solid #97b1b621; color: #bdcdd5; font-size: .8rem; line-height: 1.55; }
.log li:last-child { border-bottom: 0; }
.welcome { padding: clamp(18px, 3vw, 32px); }
.welcome h1, .welcome h2 { margin-bottom: .6rem; }
.welcome p { max-width: 65ch; margin: .5rem 0 .8rem; color: var(--muted); }
dialog {
  width: min(570px, calc(100% - 1.5rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 1.1rem;
  border: 1px solid #61808b;
  border-radius: 16px;
  background: #122432;
  color: var(--text);
  box-shadow: 0 24px 80px #0008;
}
dialog::backdrop { background: #02101bd9; }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
dialog h2, dialog h3 { font-size: 1.15rem; }
dialog p { margin: .5rem 0; color: #c8d8df; font-size: .9rem; }
.dialog-card { display: grid; gap: .8rem; min-width: 0; }
.dialog-card img, img.dialog-card { display: block; max-width: min(100%, 285px); max-height: 46vh; margin-inline: auto; border-radius: 7px; object-fit: contain; }
.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: .55rem; }
.zone-card { display: grid; align-content: start; gap: .25rem; overflow: hidden; padding: .3rem; border-radius: 6px; font-size: .75rem; }
.zone-card img { display: block; width: 100%; height: auto; border-radius: 4px; }
button img { user-select: none; -webkit-user-drag: none; }

@media (min-width: 1180px) {
  .console { position: sticky; top: .9rem; }
}
@media (max-width: 950px) {
  .layout { gap: .75rem; }
  .console > section { padding: .8rem; }
  .playerbar .stats { gap: .25rem; }
  .playerbar .chip, .playerbar .tag, .playerbar .counter { font-size: .68rem; }
}
@media (max-width: 760px) {
  .topbar { min-height: 60px; gap: .5rem; padding: .65rem .85rem; }
  .tools { gap: .3rem; }
  .tools button, .tools a { padding: .35rem .52rem; font-size: .75rem; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: .75rem .65rem 1.4rem; }
  .statusbar { margin-bottom: .45rem; }
  .phase { padding: .2rem .38rem; }
  .mat { padding: .45rem .55rem; border-radius: 12px; }
  .unit, .empty { width: min(100%, 138px); height: clamp(107px, 18vh, 150px); }
  .playerbar { min-height: 39px; }
  .hand-area { padding: .6rem; }
  .hand-card { flex-basis: clamp(85px, 20vw, 108px); }
  .hand-card img { height: 84px; }
  .console { gap: .65rem; }
  .log { max-height: 14rem; }
}
@media (max-width: 460px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .brand { gap: .45rem; }
  .brand img { width: 30px; height: 30px; }
  .layout { padding-inline: .4rem; }
  .mat { padding: .35rem; }
  .lane { padding: .23rem; }
  .lanes { gap: .28rem; }
  .unit, .empty { width: 100%; height: clamp(95px, 28vw, 125px); }
  .unit .caption { padding: .9rem .25rem .25rem; font-size: .66rem; }
  .unit .caption b, .unit .caption strong { font-size: .75rem; }
  .playerbar { gap: .25rem; }
  .playerbar .stats { justify-content: flex-start; }
  .playerbar h3, .playerbar strong { font-size: .8rem; }
  .playerbar .counter, .playerbar .chip, .playerbar .tag { min-height: 20px; padding: .15rem .32rem; }
  .hand-card { flex-basis: 84px; }
  .console section p { font-size: .84rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
