:root{
  color-scheme: dark;
  --bg0:#05070D;
  --bg1:#070A10;
  --card: rgba(255,255,255,.04);
  --stroke: rgba(255,255,255,.10);
  --stroke2: rgba(255,255,255,.14);
  --text:#EAF0FF;
  --muted: rgba(234,240,255,.72);
  --cyan:#00E5FF;
  --mag:#FF3B6B;
  --vio:#BFA7FF;
  --shadow: 0 16px 50px rgba(0,0,0,.35);
  --r: 20px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:
    radial-gradient(1200px 600px at 20% 10%, rgba(0,229,255,.12), transparent 55%),
    radial-gradient(900px 500px at 80% 30%, rgba(191,167,255,.12), transparent 55%),
    radial-gradient(900px 500px at 50% 120%, rgba(255,59,107,.08), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Mobile: allow page scroll; reduce unwanted zoom on controls */
body{ touch-action: pan-y; }
canvas{ touch-action: manipulation; }
button, .btn, a{ touch-action: manipulation; }
button, .btn{ -webkit-user-select:none; user-select:none; }

a{color:inherit}
.muted{color:var(--muted)}
.mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace}
.small{font-size:13px}

.hdr{
  padding:18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,0));
  backdrop-filter: blur(10px);
  position: sticky; top:0; z-index:10;
  display:flex; gap:16px; align-items:center; justify-content:space-between;
}
.brand{display:flex; gap:14px; align-items:center}
.logo{
  width:44px;height:44px;border-radius:16px;
  background: radial-gradient(circle at 30% 30%, var(--vio), var(--cyan) 60%, #0C0F1B);
  box-shadow: 0 0 30px rgba(0,229,255,.18);
  border: 1px solid rgba(255,255,255,.10);
}
.txt .h1{
  font-weight:950;
  letter-spacing:.2px;
  font-size:16px;
}
.txt .sub{margin-top:6px;font-size:13px;color:var(--muted)}

.wrap{max-width:1180px;margin:0 auto;padding:18px}

.card{
  border:1px solid rgba(255,255,255,.10);
  background: var(--card);
  border-radius: var(--r);
  padding:14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.grid{display:grid;grid-template-columns:1.35fr .65fr;gap:14px;margin-top:14px}
@media(max-width:980px){.grid{grid-template-columns:1fr}}

.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
.row.space{justify-content:space-between}

.k{font-size:12px;color:rgba(234,240,255,.62);text-transform:uppercase;letter-spacing:.12em}
.v{font-size:18px;font-weight:950;margin-top:4px}

.pill{
  padding:6px 10px;border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}

.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:10px 12px; border-radius:14px;
  text-decoration:none;
  border:1px solid rgba(255,255,255,.12);
  color:var(--text);
  background: linear-gradient(180deg, rgba(0,229,255,.12), rgba(0,229,255,.06));
  cursor:pointer; user-select:none;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{background: linear-gradient(180deg, rgba(0,229,255,.16), rgba(0,229,255,.08)); border-color: rgba(255,255,255,.18)}
.btn:active{transform: translateY(1px)}
.btn.ghost{background: rgba(255,255,255,.04)}
.btn.big{
  padding:14px 14px;
  font-size:14px;
  font-weight:950;
  border-radius: 18px;
}
.right{display:flex;gap:10px}

.canvasWrap{
  width:100%;
  aspect-ratio: 16/9;
  max-height: 72vh;
}
canvas{
  width:100%; height:100%;
  display:block;
  border-radius: 22px;
  border:1px solid rgba(255,255,255,.10);
  background: #04060B;
}

.hint{margin-top:10px;font-size:13px;color:var(--muted)}
.sep{height:1px;background:rgba(255,255,255,.10);margin:12px 0}

.side .stat{flex:1;min-width:140px}
.board{display:flex;flex-direction:column;gap:8px}
.rowItem{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 12px;border-radius:16px;border:1px solid rgba(255,255,255,.08);
  background:rgba(0,0,0,.22);
}
.badge{
  width:28px;height:28px;border-radius:10px;display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);font-weight:950
}

.mobileControls{
  display:none;
  gap:10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top:12px;
}

/* Desktop-only action row (hidden on small screens to avoid overlapping with the big mobile controls) */
.desktopControls{display:flex}
@media(max-width:720px){
  .hideMobile{display:none}
  .desktopControls{display:none}
  .mobileControls{display:grid}
  .hdr{flex-direction:column; align-items:flex-start}
  .right{width:100%}
  .right .btn{flex:1}
  .wrap{padding:14px}
  .canvasWrap{aspect-ratio: 1/1; max-height: 74vh}
}

input{
  width:100%;
  padding:12px 12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(0,0,0,.22);
  color:var(--text);
  outline:none;
  font-size:16px; /* prevent iOS zoom on focus */
}

.ftr{padding:16px;text-align:center;font-size:12px;color:var(--muted)}


.modal{
  position: fixed; inset:0;
  background: rgba(0,0,0,.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index: 30;
}
.modal[aria-hidden="false"]{display:flex}
.modalCard{
  width: min(720px, 100%);
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(10,12,18,.92);
  box-shadow: 0 22px 80px rgba(0,0,0,.55);
  padding: 16px;
}
.modalCard p{margin:10px 0}


/* Mobile ergonomics:
   - allow vertical page scroll (important for Arcade on mobile)
   - still block pinch/double-tap zoom interactions inside the game canvas */
html, body{
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}
canvas{
  touch-action: none; /* block pinch zoom / double-tap zoom on the arena */
}

/* Multiplayer: allow vertical scrolling even when swiping on the canvas (mobile UX)
   while still blocking pinch-zoom. */
body.mp canvas{ touch-action: pan-y; }
button, a, .btn{
  touch-action: manipulation;
}
input{
  font-size:16px; /* prevents iOS focus-zoom */
}


/* ===== MOBILE UI UPGRADE v20 ===== */
* {
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin:0;
  padding:0;
  height:100%;
  user-select:none;
  -webkit-user-select:none;
  -webkit-touch-callout:none;
}

@media (max-width: 768px) {

  .hdr {
    padding:10px;
  }

  .h1 {
    font-size:18px;
  }

  .wrap {
    padding:10px;
  }

  .card {
    padding:14px;
    border-radius:14px;
  }

  .row {
    flex-direction:column;
    gap:10px;
  }

  .btn {
    width:100%;
    padding:14px;
    font-size:16px;
    border-radius:12px;
  }

  .mobile-controls {
    position:fixed;
    bottom:0;
    left:0;
    width:100%;
    display:flex;
    justify-content:space-around;
    padding:12px;
    background:rgba(0,0,0,0.85);
    backdrop-filter:blur(8px);
  }

  .mobile-controls button {
    flex:1;
    margin:0 6px;
    font-size:16px;
  }
}


/* ===== DESKTOP LAYOUT FIX v21 ===== */

body {
  overflow-x: hidden; /* prevent side scroll */
}

.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

canvas {
  display: block;
  margin: 0 auto; /* center circle */
}

.card {
  box-sizing: border-box;
  max-width: 100%;
}



/* ===== SAFARI LAYOUT FIX v22 ===== */
.main-grid{
  display:grid;
  grid-template-columns: minmax(0,1fr) 420px;
  gap:24px;
  align-items:start;
}

@media (max-width: 1200px){
  .main-grid{ grid-template-columns: 1fr; }
}

.canvasWrap{
  width:100%;
  max-width: 920px;
  margin: 0 auto;
}

canvas{
  width:100%;
  height: min(520px, 62vh);
  max-width: 920px;
  margin: 0 auto;
}

/* mobile-only sizing */
@media (max-width: 768px){
  canvas{
    height: 60vh;
  }
}


/* ===== FLOATING TITLE v23 ===== */
.floating-title{
  position:fixed;
  top:20px;
  left:50%;
  transform:translateX(-50%);
  font-size:28px;
  font-weight:800;
  letter-spacing:1px;
  color:white;
  opacity:0;
  pointer-events:none;
  transition:opacity 0.6s ease, transform 0.6s ease;
  z-index:1000;
}

.floating-title.visible{
  opacity:0.85;
  transform:translateX(-50%) translateY(0);
}

@media (max-width:768px){
  .floating-title{
    font-size:20px;
    top:12px;
  }
}


/* ===== MOBILE SCROLL ENABLE v25 ===== */
html, body{
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* allow vertical pan on the page; keep canvas protected */
body{
  touch-action: pan-y;
}
