:root{
  --bg0:#070812;
  --bg1:#0b1230;
  --card:#0d1538cc;
  --stroke:#ffffff1f;
  --stroke2:#ffffff33;
  --text:#eaf0ff;
  --muted:#b7c3ffb3;
  --accent:#7cf7ff;
  --accent2:#b18cff;
  --good:#78ffb2;
  --bad:#ff7aa2;
  --shadow: 0 18px 60px rgba(0,0,0,.55);
  --radius:16px;
  /* Header + stage padding + margin so the square board never exceeds the window */
  --board-layout-reserve: max(12rem, 120px);
}

*{box-sizing:border-box}
html{
  height:100%;
  height:100dvh;
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-text-size-adjust:100%;
}
body{
  margin:0;
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  height:100dvh;
  max-height:100dvh;
  overflow:hidden;
  overscroll-behavior:none;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
  -webkit-touch-callout:none;
  user-select:none;
  -webkit-user-select:none;
  -moz-user-select:none;
  -ms-user-select:none;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 800px at 20% 10%, #1a2a66 0%, transparent 55%),
    radial-gradient(900px 700px at 85% 15%, #2a1758 0%, transparent 58%),
    radial-gradient(1200px 900px at 40% 105%, #0b3b57 0%, transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app{
  min-height:100%;
  min-height:100dvh;
  max-height:100dvh;
  height:100%;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  -webkit-touch-callout:none;
  user-select:none;
  -webkit-user-select:none;
}

.topbar{
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  padding:16px 16px 10px;
  flex-shrink:0;
  min-width:0;
  flex-wrap:wrap;
  row-gap:10px;
}

.brand{
  min-width:0;
  flex:1 1 12rem;
}

.topbar .hud{
  flex-shrink:0;
  min-width:0;
}

.brand__title{
  font-weight:800;
  letter-spacing:.2px;
  font-size:18px;
  line-height:1.15;
}
.brand__subtitle{
  font-size:12px;
  color:var(--muted);
  margin-top:4px;
}

.hud{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.hud__item{
  padding:10px 12px;
  border:1px solid var(--stroke);
  border-radius:12px;
  background:linear-gradient(180deg, #0b153d80, #060a1e80);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}
.hud .label{
  font-size:11px;
  color:var(--muted);
}
.hud .value{
  margin-top:2px;
  font-weight:700;
  font-size:14px;
}

.btn{
  appearance:none;
  border:1px solid var(--stroke2);
  color:var(--text);
  background:linear-gradient(180deg, #121c49, #0a1031);
  border-radius:12px;
  padding:10px 14px;
  font-weight:700;
  cursor:pointer;
  transition: transform .08s ease, border-color .15s ease, filter .15s ease;
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
}
.btn--chip{
  padding:8px 10px;
  border-radius:999px;
  font-weight:800;
  letter-spacing:.2px;
}
.btn--chip.is-active{
  border-color:#7cf7ff88;
  box-shadow: 0 12px 28px rgba(0,0,0,.35), 0 0 0 2px rgba(124,247,255,.12) inset;
}
.btn:hover{border-color:#ffffff55; filter:brightness(1.06)}
.btn:active{transform: translateY(1px) scale(.99)}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn--primary{
  border-color:#7cf7ff66;
  background:linear-gradient(180deg, #173a57, #0e163d);
}

.langSwitch{
  display:flex;
  gap:8px;
  align-items:center;
  padding:6px;
  border:1px solid var(--stroke);
  border-radius:999px;
  background:linear-gradient(180deg, #0b153d80, #060a1e80);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}

.stage{
  flex:1;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:8px 16px 16px;
}

/* Square board: side <= min(viewport width, viewport height minus chrome) so nothing clips on resize */
.boardCard{
  width:min(
    95vw,
    calc(100vh - var(--board-layout-reserve)),
    calc(100dvh - var(--board-layout-reserve)),
    calc(100svh - var(--board-layout-reserve)),
    760px
  );
  max-width:100%;
  aspect-ratio: 1 / 1;
  position:relative;
  border-radius:var(--radius);
  background: linear-gradient(180deg, #0e1a4780, #070a1e80);
  border:1px solid var(--stroke);
  box-shadow: var(--shadow);
  overflow:hidden;
  -webkit-touch-callout:none;
  user-select:none;
  -webkit-user-select:none;
}

@media (min-width: 768px){
  .boardCard{
    width:min(
      94vw,
      calc(100vh - var(--board-layout-reserve)),
      calc(100dvh - var(--board-layout-reserve)),
      calc(100svh - var(--board-layout-reserve)),
      880px
    );
  }
}

@media (min-width: 1100px){
  .boardCard{
    width:min(
      92vw,
      calc(100vh - var(--board-layout-reserve)),
      calc(100dvh - var(--board-layout-reserve)),
      calc(100svh - var(--board-layout-reserve)),
      1040px
    );
  }
}

@media (min-width: 1440px){
  .boardCard{
    width:min(
      88vw,
      calc(100vh - var(--board-layout-reserve)),
      calc(100dvh - var(--board-layout-reserve)),
      calc(100svh - var(--board-layout-reserve)),
      1200px
    );
  }
}

.boardCanvas{
  width:100%;
  height:100%;
  display:block;
  touch-action:manipulation;
  -webkit-touch-callout:none;
  user-select:none;
  -webkit-user-select:none;
  -webkit-user-drag:none;
  outline:none;
}

.overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background: radial-gradient(900px 600px at 50% 40%, #00000077, #000000aa);
  backdrop-filter: blur(4px);
}
.overlay[hidden]{
  display:none !important;
}
.overlay__panel{
  width:min(520px, 100%);
  border-radius:16px;
  border:1px solid var(--stroke2);
  background: linear-gradient(180deg, #101a46e6, #060814e6);
  box-shadow: var(--shadow);
  padding:16px;
  text-align:center;
}
.overlay__title{
  font-weight:900;
  font-size:22px;
  letter-spacing:.2px;
}
.overlay__actions{
  margin-top:14px;
  display:flex;
  justify-content:center;
}
.overlay__hint{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
}

.footer{
  padding:10px 16px 16px;
  color:var(--muted);
  font-size:12px;
  display:flex;
  justify-content:center;
}
.footer__note{
  opacity:.9;
}

@media (min-width: 900px){
  .brand__title{font-size:20px}
}

