:root {
  /* Responsive cell: never bigger than 32px (drag math in Placement depends on
     a fixed 32px pitch), but shrinks so the 10-col board fits mobile width.
     No A–J / 1–10 label gutter anymore, so less width is reserved. */
  --cell: min(32px, calc((100vw - 40px) / 11));
  --navy: #07182f;
  --navy2: #0d2745;
  --steel: #1d4e7e;
  --sky: #6fc3f3;
  --water: #0e3a6b;
  --grid-line: rgba(120, 190, 255, 0.16);
  --ship: #66727c;
  --ship-edge: #2c343b;
  --hit: #ff4d5e;
  --miss: #bfe2ff;
  --gold: #f0c14b;
  --panel: rgba(7, 22, 44, 0.72);
  --panel-brd: rgba(120, 180, 255, 0.16);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  color: #eaf2ff;
  min-height: 100dvh;
  overflow-x: hidden;
  background: linear-gradient(180deg, #04101f 0%, #072142 40%, #0a325f 100%);
  /* app-like: no pinch-zoom / double-tap-zoom, no rubber-band bounce, no
     long-press text selection or grey tap flash. Inputs re-enable selection. */
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }

/* subtle grain to break digital flatness */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- animated ocean background ---------- */
.ocean-bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.ocean-bg::before {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(900px 500px at 75% -5%, rgba(80,160,230,.45), transparent 60%),
    radial-gradient(700px 400px at 15% 10%, rgba(40,110,180,.30), transparent 60%);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translate(0,0); } to { transform: translate(-30px, 20px); } }
.wave {
  position: absolute; left: -50%; width: 200%; height: 220px; bottom: 0;
  background: radial-gradient(ellipse at 50% 100%, rgba(60,140,210,.22), transparent 70%);
  border-radius: 45%;
  animation: roll 12s linear infinite;
}
.wave.w2 { bottom: -40px; opacity: .6; animation-duration: 17s; animation-direction: reverse; }
.wave.w3 { bottom: -80px; opacity: .4; animation-duration: 22s; }
@keyframes roll { from { transform: rotate(0deg) translateX(0); } to { transform: rotate(360deg); } }

.app { max-width: 480px; margin: 0 auto; padding: 14px 14px 60px; position: relative; z-index: 1; }

h1, h2, h3, .title, .ttl { font-family: "Oswald", sans-serif; letter-spacing: 1px; text-wrap: balance; }

/* data/figures read cleaner with fixed-width digits */
.scoreboard b, .counter, .room-code-box .code, .code, .power-btn .pc, input.code-input {
  font-variant-numeric: tabular-nums;
}

/* keyboard focus ring (a11y) — only on keyboard nav, not mouse press */
.btn:focus-visible, .mode-opt:focus-visible, .power-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 18px; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo .badge {
  width: 50px; height: 50px; border-radius: 12px;
  background: linear-gradient(160deg, var(--gold), #c8961f);
  display: grid; place-items: center; font-size: 26px;
  box-shadow: 0 6px 18px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.25);
}
.logo h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: 2px; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.lobby h2, .modal h2 { letter-spacing: -.5px; }
.logo small { color: var(--sky); letter-spacing: 3px; text-transform: uppercase; font-size: 11px; }

/* glass panels — true glassmorphism: deeper blur + saturation lift */
.lobby, .room-banner, .modal, .log {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
/* shared edge-refraction highlight (1px top light + glass top sheen) */
.log {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10), inset 0 -16px 36px rgba(2,12,30,.3);
}

/* Lobby */
.lobby {
  max-width: 480px; margin: 6vh auto 0; border-radius: 20px; padding: 34px 30px;
  box-shadow: 0 24px 70px rgba(2,12,30,.6), inset 0 1px 0 rgba(255,255,255,.12), inset 0 -22px 50px rgba(2,12,30,.35);
  animation: rise .55s cubic-bezier(.34,1.4,.4,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.lobby h2 { margin: 0 0 6px; font-size: 26px; }
.lobby p.sub { margin: 0 0 24px; color: #a9ccec; font-size: 14px; }
.field { margin-bottom: 14px; }
label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #a9ccec; margin-bottom: 6px; }
input.code-input {
  width: 100%; padding: 15px 16px; font-size: 24px; letter-spacing: 8px;
  text-transform: uppercase; text-align: center; font-family: "Oswald";
  border-radius: 12px; border: 1px solid rgba(150,200,255,.25);
  background: rgba(255,255,255,.06); color: #fff; outline: none; transition: box-shadow .2s, border-color .2s;
}
input.code-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240,193,75,.25); }
input.code-input::placeholder { letter-spacing: 6px; color: #5f81a8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; border: none; border-radius: 12px; cursor: pointer;
  font-family: "Oswald"; font-size: 16px; letter-spacing: 1px; text-transform: uppercase;
  transition: transform .08s ease, filter .15s ease, box-shadow .2s; color: #07203f; font-weight: 600;
  position: relative; overflow: hidden;
}
.btn::after {
  content:""; position:absolute; top:0; left:-120%; width:60%; height:100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent);
  transform: skewX(-20deg); transition: left .5s;
}
.btn:hover::after { left: 140%; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(160deg, var(--gold), #cf9b23); box-shadow: 0 8px 22px rgba(240,193,75,.28); }
.btn.steel { background: linear-gradient(160deg, #7cc0f0, #2f6ea3); color: #fff; box-shadow: 0 8px 22px rgba(47,110,163,.35); }
.btn.ghost { background: rgba(255,255,255,.07); color: #cfe2f7; border: 1px solid rgba(150,200,255,.2); }
.btn.ghost::after { display: none; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled::after { display: none; }
.divider { text-align: center; color: #5f81a8; margin: 20px 0; font-size: 12px; position: relative; }
.divider::before, .divider::after { content:""; position:absolute; top:50%; width:38%; height:1px; background: rgba(150,200,255,.16); }
.divider::before { left:0; } .divider::after { right:0; }
.error { color: #ffb3bb; background: rgba(255,77,94,.15); border:1px solid rgba(255,77,94,.4); padding:10px 12px; border-radius:8px; font-size:13px; margin-bottom:12px; }

/* Room / banner */
.room-banner {
  border-radius:16px; padding:16px 22px; display:flex; align-items:center; justify-content:space-between;
  margin-bottom:20px; box-shadow: 0 10px 30px rgba(2,12,30,.4), inset 0 1px 0 rgba(255,255,255,.10);
}
.room-code-box { display:flex; align-items:center; gap:14px; }
.room-code-box .code {
  font-family:"Oswald"; font-size:34px; letter-spacing:8px; color: var(--gold);
  background: rgba(0,0,0,.28); padding: 6px 18px; border-radius:10px; border:1px dashed rgba(240,193,75,.5);
  text-shadow: 0 0 14px rgba(240,193,75,.4);
}
.code-copy { cursor:pointer; position:relative; user-select:all; transition:transform .1s, border-color .2s; }
.code-copy:hover { border-color:var(--gold); }
.code-copy:active { transform:scale(.96); }
.code-copy .copied-tag { margin-left:8px; font-size:.6em; color:#7ff0aa; letter-spacing:0; vertical-align:middle; }
.copy-hint { font-size:12px; color:#9fc0e0; }
.status-pill { padding:7px 16px; border-radius:22px; font-size:13px; font-family:"Oswald"; letter-spacing:1px; }
.pill-wait { background: rgba(240,193,75,.16); color: var(--gold); }
.pill-ready { background: rgba(111,195,243,.2); color: var(--sky); }
.pill-turn { background: rgba(64,200,120,.22); color:#7ff0aa; box-shadow: 0 0 18px rgba(64,200,120,.3); animation: pulse 1.6s ease-in-out infinite; }
.pill-enemy { background: rgba(255,77,94,.2); color:#ff9aa4; }
@keyframes pulse { 0%,100%{ filter: brightness(1);} 50%{ filter: brightness(1.35);} }
.turn-timer { font-weight:700; opacity:.9; font-variant-numeric: tabular-nums; }
.turn-timer.low { color:#ff9aa4; animation: pulse 1s ease-in-out infinite; }

/* Boards */
.boards { display:flex; gap:38px; flex-wrap:wrap; justify-content:center; align-items:flex-start; }
.board-title { text-align:center; font-family:"Oswald"; font-size:18px; letter-spacing:2px; margin-bottom:12px; text-transform:uppercase; }
.board-title.enemy { color:#ff9aa4; }
.board-title.own { color: var(--sky); }

.grid {
  display:grid; gap:2px; padding:6px; border-radius:12px; position:relative;
  background:
    repeating-linear-gradient(0deg, rgba(120,190,255,.05) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #0c3a6e, #08284c);
  box-shadow: 0 18px 50px rgba(2,12,30,.55), inset 0 0 0 1px rgba(120,190,255,.18), inset 0 0 60px rgba(0,0,0,.4);
}
.cell {
  width:var(--cell); height:var(--cell); border-radius:5px; display:grid; place-items:center; position:relative;
  background: linear-gradient(180deg, rgba(46,110,170,.45), rgba(12,52,100,.7));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  transition: background .12s ease, box-shadow .12s ease;
}
.grid.enemy .cell.shootable { cursor:crosshair; }
.grid.enemy .cell.shootable:hover {
  background: rgba(111,195,243,.5);
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 16px rgba(240,193,75,.5);
}
.cell.ship {
  background: linear-gradient(180deg, #7a8791, #444e57);
  box-shadow: inset 0 0 0 1px var(--ship-edge), inset 0 2px 4px rgba(255,255,255,.15);
}
.cell.hit { background: radial-gradient(circle, #ff5a67, #b71f2c); animation: boom .45s ease-out; }
.cell.hit::after { content:"\1F525"; font-size:18px; }
/* thuyền đã cháy rụi — thay đốm lửa bằng xác thuyền cháy đen */
.cell.sunk {
  background: linear-gradient(180deg, #3a3330, #181412) !important;
  box-shadow: inset 0 0 0 1px rgba(120,90,70,.5), inset 0 2px 6px rgba(0,0,0,.7) !important;
  animation: none !important;
}
.cell.sunk::after {
  content:"\1F6A2" !important; font-size:17px;
  filter: grayscale(1) brightness(.45) contrast(1.2); opacity:.9;
}
.cell.miss { background: linear-gradient(180deg, rgba(46,110,170,.3), rgba(12,52,100,.5)); }

/* ô vừa bị bắn — nhấp nháy vòng sáng để dễ thấy địch/mình đánh vào đâu */
.cell.flash { z-index:2; }
.cell.flash::before {
  content:""; position:absolute; inset:-3px; border-radius:7px; pointer-events:none;
  border:3px solid var(--gold); box-shadow:0 0 16px rgba(240,193,75,.9);
  animation: flashring 2s ease-out forwards;
}
@keyframes flashring {
  0%   { opacity:1; transform:scale(1.25); }
  30%  { opacity:1; transform:scale(1); }
  100% { opacity:0; transform:scale(1); }
}

/* chọn chế độ khi tạo phòng */
.mode-pick { display:flex; gap:10px; margin:6px 0 12px; }
.mode-opt {
  flex:1; display:flex; flex-direction:column; gap:2px; align-items:flex-start;
  padding:10px 12px; border-radius:10px; cursor:pointer; text-align:left;
  background:rgba(8,30,58,.6); border:1px solid rgba(120,190,255,.25); color:#cfe8ff;
}
.mode-opt b { font-size:15px; }
.mode-opt span { font-size:11px; opacity:.7; }
.mode-opt.on { border-color:var(--gold); box-shadow:0 0 14px rgba(240,193,75,.4); background:rgba(240,193,75,.12); }

/* ô power-up trên biển địch */
.cell.powerup { cursor:pointer; }
.cell.powerup { font-size:17px; animation: pulsepow 1.4s ease-in-out infinite; }
@keyframes pulsepow { 0%,100%{ box-shadow: inset 0 0 0 2px rgba(240,193,75,.6); } 50%{ box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px rgba(240,193,75,.7); } }
.cell.revealed::after { content:"\1F6A2"; font-size:15px; opacity:.55; filter: drop-shadow(0 0 4px rgba(255,90,110,.8)); }
.cell.aim { box-shadow: inset 0 0 0 2px var(--gold), 0 0 12px rgba(240,193,75,.6) !important; }
/* mìn nước trên hạm đội của mình */
.cell.mine { font-size:16px; box-shadow: inset 0 0 0 2px rgba(255,140,60,.7); }
/* thông báo nổi (vd: dẫm phải mìn) */
.notice-toast {
  position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:200;
  background:linear-gradient(135deg,#b5371f,#e0531f); color:#fff; font-weight:700;
  padding:12px 20px; border-radius:12px; box-shadow:0 6px 24px rgba(0,0,0,.45);
  border:1px solid rgba(255,180,120,.6); max-width:90vw; text-align:center;
  animation: noticepop .25s ease-out;
}
@keyframes noticepop { from{ opacity:0; transform:translateX(-50%) translateY(-10px);} to{ opacity:1; transform:translateX(-50%) translateY(0);} }

/* đối thủ tạm mất kết nối — banner nổi trên cùng, đếm ngược grace */
.offline-banner {
  position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:190;
  background:linear-gradient(135deg,#8a6d1f,#b8902a); color:#fff; font-weight:600;
  padding:11px 18px; border-radius:12px; box-shadow:0 6px 24px rgba(0,0,0,.45);
  border:1px solid rgba(255,220,140,.6); max-width:92vw; text-align:center; font-size:13px;
  animation: noticepop .25s ease-out;
}

/* thanh power-up trong kho */
.powerbar { display:flex; gap:6px; justify-content:center; margin:0 auto 10px; flex-wrap:wrap; max-width:520px; }
.power-btn {
  position:relative; display:flex; flex-direction:column; align-items:center; gap:1px;
  padding:6px 10px; min-width:70px; border-radius:10px; cursor:pointer;
  background:rgba(8,30,58,.7); border:1px solid rgba(120,190,255,.3); color:#cfe8ff;
}
.power-btn .pi { font-size:18px; }
.power-btn .pn { font-size:10px; opacity:.85; }
.power-btn .pc { position:absolute; top:-6px; right:-6px; background:var(--gold); color:#06203f; font-size:11px; font-weight:700; border-radius:10px; padding:0 6px; }
.power-btn:disabled { opacity:.4; cursor:default; }
.power-btn.aiming { border-color:var(--gold); box-shadow:0 0 14px rgba(240,193,75,.6); background:rgba(240,193,75,.15); }
/* banner ngắm dạng nổi (fixed) để không làm xê dịch bố cục -> tránh giật scroll trên mobile */
.aim-banner { position:fixed; left:50%; bottom:14px; transform:translateX(-50%); z-index:150; width:max-content; max-width:92vw; background:rgba(40,30,8,.96); border:1px solid var(--gold); color:#ffe9b0; padding:9px 14px; border-radius:12px; font-size:13px; text-align:center; box-shadow:0 6px 22px rgba(0,0,0,.5); }

/* bảng điểm 2 người trong room */
.scoreboard {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  margin:0 auto 14px; padding:8px 12px; max-width:420px;
  background:rgba(8,30,58,.7); border:1px solid rgba(120,190,255,.25);
  border-radius:12px; color:#cfe8ff;
}
.scoreboard b { font-size:20px; color:var(--gold); margin:0 4px; }
.sc-sep { opacity:.5; }

/* Player cards on each side of the scoreboard */
.pcard { display:flex; align-items:center; gap:8px; flex:1; min-width:0; padding:3px; border-radius:10px; border:1px solid transparent; transition:border-color .2s, background .2s; }
.pcard.opp { flex-direction:row-reverse; text-align:right; }
.pcard.active { border-color:rgba(127,240,170,.45); background:rgba(127,240,170,.08); }
.pc-avatar { width:38px; height:38px; border-radius:50%; object-fit:cover; flex:none; background:#0d2236; }
.pc-fallback { display:flex; align-items:center; justify-content:center; background:var(--sky); color:#06182c; font-weight:700; font-size:17px; text-transform:uppercase; }
.pc-meta { display:flex; flex-direction:column; min-width:0; }
.pcard.opp .pc-meta { align-items:flex-end; }
.pc-name { font-size:13px; color:#dbe7f3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:96px; }
.pc-score { font-size:22px; font-weight:700; color:var(--gold); line-height:1; }

/* Countdown ring */
.turn-ring { position:relative; flex:none; width:56px; height:56px; display:flex; align-items:center; justify-content:center; }
.turn-ring-sec { position:absolute; font-size:18px; font-weight:700; font-variant-numeric:tabular-nums; }
.turn-ring.low { animation:pulse 1s ease-in-out infinite; }
.cell.miss::after {
  content:""; width:11px; height:11px; border-radius:50%;
  background: radial-gradient(circle, #fff, var(--miss)); opacity:.85;
  box-shadow: 0 0 8px rgba(191,226,255,.6); animation: splash .4s ease-out;
}
@keyframes boom { 0%{ transform: scale(.3); filter: brightness(2);} 60%{ transform: scale(1.25);} 100%{ transform: scale(1);} }
@keyframes splash { 0%{ transform: scale(0);} 70%{ transform: scale(1.4);} 100%{ transform: scale(1);} }

/* labels (A–J / 1–10) removed — grid wraps tight with no gutter */
.grid-outer { display:inline-block; }

/* hit counter bar */
.counter { display:flex; align-items:center; gap:8px; justify-content:center; margin-top:12px; font-size:12px; color:#a9ccec; font-family:"Oswald"; letter-spacing:1px; }
.counter .bar { flex:1; height:8px; max-width:180px; border-radius:6px; background: rgba(0,0,0,.3); overflow:hidden; }
.counter .fill { height:100%; border-radius:6px; transition: width .4s ease; }
.counter .fill.enemy { background: linear-gradient(90deg, #ff7a86, #b71f2c); }
.counter .fill.own { background: linear-gradient(90deg, #7ff0aa, #2f9e63); }

/* placement panel */
/* Placement: hint + actions on top, board below */
.place-wrap { display:flex; flex-direction:column; align-items:center; gap:12px; }
.place-hint { max-width:440px; text-align:center; font-size:13px; color:#a9ccec; line-height:1.55; margin:0; }
.place-actions { display:flex; gap:10px; justify-content:center; width:100%; max-width:440px; }
.place-actions .btn { flex:1; }
.place-wrap .board-wrap { width:100%; display:flex; flex-direction:column; align-items:center; }
.controls { display:flex; gap:8px; }
.controls .btn { padding:11px; font-size:13px; }

/* floating ghost that follows finger/cursor while dragging */
.drag-ghost { position:fixed; z-index:999; pointer-events:none; opacity:.92;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.6)); }
.drag-ghost .ship-fig { position:relative; }

/* ship figure (svg wrapper); rotates for vertical orientation */
.ship-fig { position:relative; }
.ship-fig.v { position:absolute; top:50%; left:50%; transform: translate(-50%,-50%) rotate(90deg); transform-origin:center; }
.ship-svg { display:block; }

/* placed ship overlay on the grid */
.ship-overlay { position:absolute; cursor:grab; z-index:3; touch-action:none; filter: drop-shadow(0 5px 10px rgba(0,0,0,.55)); }
.ship-overlay:active { cursor:grabbing; }
.ship-overlay .ship-fig.v { width:auto; }

/* placement preview highlight */
.cell.preview-ok { background: rgba(120,240,160,.45) !important; box-shadow: inset 0 0 0 2px #6fe3a0; }
.cell.preview-bad { background: rgba(255,90,110,.45) !important; box-shadow: inset 0 0 0 2px #ff5a6e; }

.toolbar { display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.toolbar .btn { width:auto; padding:10px 16px; }

.overlay { position:fixed; inset:0; background:rgba(3,10,22,.8); display:grid; place-items:center; z-index:50; backdrop-filter: blur(4px); animation: rise .3s both; }
.modal { border-radius:20px; padding:38px 42px; text-align:center; max-width:380px; box-shadow:0 28px 80px rgba(2,12,30,.7), inset 0 1px 0 rgba(255,255,255,.14), inset 0 -24px 60px rgba(2,12,30,.4); animation: rise .45s cubic-bezier(.34,1.4,.4,1) both; }
.modal h2 { margin:0 0 10px; font-size:38px; }
.modal.win h2 { color:#7ff0aa; text-shadow: 0 0 24px rgba(64,200,120,.5); }
.modal.lose h2 { color:#ff9aa4; }
.modal p { color:#c4ddf6; margin:0 0 24px; }

.log { margin-top:20px; max-height:130px; overflow:auto; font-size:13px; color:#c4ddf6; border-radius:10px; padding:10px 16px; }
.log div { padding:3px 0; border-bottom:1px solid rgba(150,200,255,.06); }
.log div:first-child { color:#fff; }

.footer-note { text-align:center; color:#5878a0; font-size:12px; margin-top:32px; }

/* ---------- high-end motion layer ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* staggered entry: boards cascade in instead of mounting at once */
  .board-wrap { animation: rise .5s cubic-bezier(.34,1.3,.4,1) both; }
  .wrap-enemy { animation-delay: .05s; }
  .wrap-own   { animation-delay: .15s; }
}

/* spring-weighted hover lift on interactive cards */
.mode-opt, .power-btn {
  transition: transform .18s cubic-bezier(.34,1.5,.45,1), box-shadow .2s ease, border-color .2s ease, background .2s ease;
}
.mode-opt:hover, .power-btn:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: rgba(240,193,75,.5);
}
.mode-opt:active, .power-btn:not(:disabled):active { transform: translateY(0); }

/* radial spotlight under the recommended/active mode card */
.mode-opt.on {
  background:
    radial-gradient(120% 120% at 50% -10%, rgba(240,193,75,.22), transparent 60%),
    rgba(240,193,75,.12);
}

@media (max-width:560px){
  /* keep cell pitch fixed (drag math depends on it); just tighten layout */
  .boards{gap:20px;}
  /* single board on mobile: auto-switches by turn (no manual tab buttons). */
  .boards.tab-enemy .wrap-own{ display:none; }
  .boards.tab-own .wrap-enemy{ display:none; }
  /* topbar gọn lại để không bị tràn / đè chữ */
  .topbar{ padding:6px 2px 14px; gap:8px; }
  .logo{ gap:8px; min-width:0; flex:1; }
  .logo .badge{ width:38px; height:38px; border-radius:10px; font-size:20px; flex:none; }
  .logo h1{ font-size:21px; letter-spacing:1px; line-height:1.05; }
  .logo small{ font-size:9px; letter-spacing:2px; white-space:nowrap; }
  .topbar .btn.ghost{ padding:5px 8px !important; font-size:11px !important; white-space:nowrap; }
  .topbar .status-pill{ font-size:11px; padding:4px 8px; white-space:nowrap; }
  /* room-banner: cho phép xuống hàng, không bóp méo pill trạng thái */
  .room-banner{ flex-wrap:wrap; gap:10px 12px; padding:12px 14px; }
  .room-banner .status-pill{ white-space:nowrap; flex:none; }
  .room-code-box{ gap:10px; flex-wrap:wrap; }
  .room-code-box .code{ font-size:22px !important; letter-spacing:4px; padding:5px 12px; }
  /* power-bar: thu gọn để 5 nút vừa 1 hàng */
  .powerbar{ gap:5px; }
  .power-btn{ min-width:0; flex:1 1 0; padding:6px 4px; }
  .power-btn .pn{ font-size:9px; line-height:1.1; }
  .power-btn .pi{ font-size:15px; }
}
@media (max-width:380px){
  .logo h1{ font-size:18px; }
  .logo small{ display:none; }
}

/* Subtle scrollbar — the Instant Games portrait container is short, so content
   scrolls; the default chunky bar looked rough. Thin + translucent. */
* { scrollbar-width: thin; scrollbar-color: rgba(120,160,210,.35) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,160,210,.35); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,160,210,.55); }

/* Room bar: own row under the topbar (room code + invite + leave). Keeps the
   topbar uncluttered so the logo/room/leave no longer overlap on mobile. */
.topbar-sound { width:auto !important; padding:6px 10px !important; font-size:14px; }
.topbar-right { display:flex; align-items:center; gap:8px; }
.profile-chip {
  display:flex; align-items:center; gap:7px; max-width:150px;
  background:var(--panel); border:1px solid var(--panel-brd); border-radius:20px; padding:3px 10px 3px 3px;
}
.profile-chip .avatar { width:28px; height:28px; border-radius:50%; object-fit:cover; flex:none; background:#0d2236; }
.profile-chip .avatar-fallback {
  display:flex; align-items:center; justify-content:center; background:var(--sky); color:#06182c; font-weight:700; font-size:14px; text-transform:uppercase;
}
.profile-chip .pname { font-size:13px; color:#dbe7f3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
@media (max-width:380px){ .profile-chip .pname { display:none; } .profile-chip { padding:3px; } }
.roombar {
  display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap;
  background: var(--panel); border:1px solid var(--panel-brd); border-radius:12px;
  padding:8px 12px; margin-bottom:14px;
}
.roombar-info { font-size:14px; color:#cfe4fb; }
.roombar .roomcode { letter-spacing:3px; color:var(--gold); font-size:16px; }
.roombar-actions { display:flex; gap:8px; align-items:center; }
.roombar-actions .btn { width:auto; padding:7px 12px; font-size:13px; white-space:nowrap; }
.chat-toggle { position:relative; }

/* Chat composer: bottom sheet to type/send (no message log). */
.chat-panel {
  position:fixed; left:50%; bottom:0; transform:translateX(-50%);
  width:min(440px, 100%); display:flex; flex-direction:column;
  background:var(--panel); border:1px solid var(--panel-brd); border-bottom:none;
  border-radius:14px 14px 0 0; box-shadow:0 -8px 30px rgba(0,0,0,.45); z-index:50;
}
.chat-head { display:flex; align-items:center; justify-content:space-between; padding:10px 14px; border-bottom:1px solid var(--panel-brd); }
.chat-emojis { display:flex; gap:4px; padding:8px 10px; flex-wrap:wrap; }
.chat-emoji { background:rgba(255,255,255,.06); border:none; border-radius:8px; font-size:20px; padding:4px 8px; cursor:pointer; }
.chat-emoji:active { background:rgba(255,255,255,.18); }
.chat-input { display:flex; gap:8px; padding:10px; border-top:1px solid var(--panel-brd); }
.chat-input input {
  flex:1; background:rgba(0,0,0,.25); border:1px solid var(--panel-brd); border-radius:10px;
  padding:9px 12px; color:#fff; font-size:16px; outline:none; /* >=16px: ngăn iOS tự zoom khi focus */
}
.chat-input .btn { padding:9px 16px; font-size:13px; }

/* Speech bubble over a player's avatar (3s ephemeral chat) */
.pc-avatar-wrap { position:relative; flex:none; }
.chat-bubble {
  position:absolute; bottom:calc(100% + 9px); left:50%; transform:translateX(-50%);
  background:#fff; color:#10243a; padding:6px 11px; border-radius:13px; font-size:14px; font-weight:600;
  white-space:normal; word-break:break-word; max-width:170px; width:max-content; text-align:center;
  box-shadow:0 5px 16px rgba(0,0,0,.4); z-index:30; pointer-events:none;
  animation:bubblePop .18s ease-out;
}
.chat-bubble::after {
  content:""; position:absolute; top:100%; left:50%; transform:translateX(-50%);
  border:6px solid transparent; border-top-color:#fff;
}
.chat-bubble.opp { background:#dff1ff; }
.chat-bubble.opp::after { border-top-color:#dff1ff; }
@keyframes bubblePop {
  from { opacity:0; transform:translateX(-50%) translateY(6px) scale(.7); }
  to   { opacity:1; transform:translateX(-50%) translateY(0) scale(1); }
}

/* How-to-play */
.help-link { margin-top:10px; opacity:.85; font-size:13px; }
.help-modal { max-width:460px; text-align:left; max-height:86vh; display:flex; flex-direction:column; }
.help-modal h2 { text-align:center; }
.help-body { overflow-y:auto; margin:6px 0 14px; padding-right:4px; }
.help-sec { margin-bottom:14px; }
.help-sec h4 { margin:0 0 4px; font-size:15px; color:var(--gold); }
.help-sec p { margin:0; font-size:14px; line-height:1.5; color:#dbe7f3; }
.help-pw { display:flex; gap:10px; align-items:flex-start; margin-top:8px; }
.help-pw-i { font-size:22px; line-height:1.2; flex:none; }
.help-pw b { display:block; font-size:14px; color:#fff; }
.help-pw span { font-size:13px; color:#aebfd0; }

/* Crawlable heading/intro for search engines + screen readers (off-screen, not display:none). */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
