/* =================== NỀN TẢNG =================== */
:root {
  --bg: #0a1624;
  --bg2: #0f2135;
  --panel: #13283f;
  --panel2: #1a3350;
  --line: #28486b;
  --text: #e8eef5;
  --muted: #8ba3bc;
  --accent: #f2b33d;
  --accent2: #e29a1f;
  --red: #e23b2e;
  --green: #4cc38a;
  --blue: #5aa9ff;
  --tray: #1f416a;
  --stencil: 'Saira Stencil One', 'Be Vietnam Pro', Impact, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200' fill='none' stroke='%23a9c8ea' stroke-opacity='.09' stroke-width='1.2'%3E%3Ccircle cx='100' cy='100' r='92'/%3E%3Ccircle cx='100' cy='100' r='80' stroke-dasharray='2 6'/%3E%3Ccircle cx='100' cy='100' r='40'/%3E%3Cpath d='M100 4v192M4 100h192M32 32l136 136M168 32L32 168'/%3E%3Cpath d='M100 14l12 86-12 86-12-86z M14 100l86-12 86 12-86 12z' fill='%23a9c8ea' fill-opacity='.05'/%3E%3C/svg%3E") no-repeat left -170px bottom -170px / 520px 520px,
    radial-gradient(ellipse at 20% -10%, rgba(90, 169, 255, .13), transparent 55%),
    radial-gradient(ellipse at 90% 110%, rgba(242, 179, 61, .07), transparent 50%),
    repeating-linear-gradient(0deg, rgba(120, 170, 220, .035) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(90deg, rgba(120, 170, 220, .035) 0 1px, transparent 1px 64px),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none;
}
input, button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
kbd {
  background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font-size: 12px;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* =================== NÚT =================== */
.btn {
  background: var(--panel2); border: 1px solid #2f5580; border-radius: 8px;
  padding: 8px 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: #24456b; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(#f7c65a, var(--accent2)); border-color: #b87a12; color: #1c1405;
  box-shadow: 0 2px 0 #9b6508, 0 6px 16px rgba(242, 179, 61, .2);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(#ffd173, #eba631); }
.btn.big { padding: 12px 20px; font-size: 16px; }
.btn.huge { padding: 16px 44px; font: 22px var(--stencil); letter-spacing: 2px; display: block; margin: 22px auto 8px; }
.btn.huge.primary:not(:disabled) { animation: cta-glow 2.2s ease-in-out infinite; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.icon { padding: 6px 10px; font-size: 17px; }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; font-weight: 500; }
.btn.link:hover { color: var(--text); background: none; }
.btn.danger { color: #ff8b80; }

/* =================== KHUNG TRANG =================== */
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 18px; background: linear-gradient(#11263e, #0b1a2c);
  position: relative; z-index: 10; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, transparent, #b8862b 20%, #f2c35d 50%, #b8862b 80%, transparent);
  opacity: .75;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font: 26px var(--stencil); color: var(--accent); letter-spacing: 3px; white-space: nowrap; text-shadow: 0 2px 0 #6b4606;
}
.logo svg { width: 30px; height: 30px; filter: drop-shadow(0 2px 0 #6b4606); }
.top-actions { display: flex; gap: 4px; }

.scoreboard {
  display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 44px; border-radius: 22px; line-height: 1;
  background: rgba(8, 20, 34, .6); border: 1px solid #1f3b5c; box-shadow: inset 0 1px 6px rgba(0, 0, 0, .4);
}
.sb-side { display: flex; align-items: center; gap: 8px; min-width: 170px; justify-content: flex-end; }
.sb-side.right { flex-direction: row-reverse; }
.sb-avatar { font-size: 24px; line-height: 1; }
.sb-name { font-weight: 700; font-size: 15px; }
.sb-name small { color: var(--muted); font-weight: 500; }
.sb-score { font: 28px/1 var(--stencil); display: flex; gap: 10px; align-items: center; }
.sb-score b { color: var(--accent); font-weight: normal; }
.sb-score i { color: var(--muted); font-style: normal; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.offline { background: var(--red); animation: pulse 1.2s infinite; }

#conn-banner {
  position: fixed; top: 60px; left: 0; right: 0; z-index: 2500; text-align: center;
  background: #8a2a1f; padding: 6px; font-weight: 600;
}

.layout { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 60px); }
#stage { overflow: auto; padding: 18px 22px 30px; position: relative; }

.center-card {
  margin: 80px auto; max-width: 420px; text-align: center; padding: 32px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.center-card p { font-size: 16px; margin: 14px 0 20px; }
.big-icon { font-size: 56px; }
.spin { animation: bob 1.6s ease-in-out infinite; }

/* =================== THANH BÊN: CHAT & NHẬT KÝ =================== */
.sidebar {
  background: var(--bg2); border-left: 1px solid #1c3858;
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid #1c3858; }
.tabs button {
  flex: 1; background: none; border: none; padding: 12px 6px; cursor: pointer; font-weight: 600;
  color: var(--muted); border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#unread { background: var(--red); color: white; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel[hidden] { display: none; }

#chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; user-select: text; }
#chat-list:empty::before {
  content: '💬\A Chưa có tin nhắn nào.\A Gửi lời chào hoặc thả một biểu cảm nhé!'; white-space: pre-line;
  margin: auto; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7;
}
.msg { display: flex; gap: 8px; align-items: flex-end; animation: msg-in .25s ease-out; }
.msg.mine { flex-direction: row-reverse; }
.msg-avatar { font-size: 22px; line-height: 1; flex: none; margin-bottom: 16px; }
.msg-body { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 82%; }
.msg.mine .msg-body { align-items: flex-end; }
.msg .bubble {
  background: var(--panel2); padding: 7px 11px; border-radius: 12px 12px 12px 3px;
  max-width: 100%; word-wrap: break-word; white-space: pre-wrap;
}
.msg.mine .bubble { background: linear-gradient(#2f6aa3, #265a8c); border-radius: 12px 12px 3px 12px; }
.msg small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.emotes { display: grid; grid-template-columns: repeat(6, 1fr); padding: 6px 8px; border-top: 1px solid #1c3858; }
.emotes button { background: none; border: none; font-size: 21px; cursor: pointer; padding: 3px; border-radius: 8px; transition: transform .1s; }
.emotes button:hover { background: var(--panel2); transform: scale(1.2); }
#chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #1c3858; }
#chat-input {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  user-select: text;
}
#chat-input:focus { outline: none; border-color: var(--accent); }

#log-list { list-style: none; margin: 0; padding: 8px 10px; overflow-y: auto; flex: 1; }
#log-list li {
  display: flex; gap: 8px; padding: 7px 8px; font-size: 13px; border-bottom: 1px solid #1a3149;
  border-left: 3px solid transparent;
}
#log-list li.mine { border-left-color: var(--blue); }
#log-list li.theirs { border-left-color: #b25fe0; }
#log-list li.hit span:last-child { color: #ffb4a8; }
#log-list .ic { flex: none; }

/* =================== BÀN CỜ =================== */
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.board-title { font: 17px var(--stencil); letter-spacing: 1.5px; color: #cfe0f1; }
.board-frame {
  position: relative;
  display: grid; grid-template-columns: 22px auto; grid-template-rows: 22px auto;
  padding: 10px 16px 16px 10px; border-radius: 16px;
  background: linear-gradient(160deg, #2a5285, var(--tray) 40%, #16335a);
  border: 2px solid #0c1d33;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .15), inset 0 -3px 0 rgba(0, 0, 0, .3), 0 12px 30px rgba(0, 0, 0, .45);
  transition: box-shadow .3s;
}
.board-wrap.enemy.active .board-frame {
  box-shadow: 0 0 0 3px var(--accent), 0 0 34px rgba(242, 179, 61, .35), 0 12px 30px rgba(0, 0, 0, .45);
}
.board-wrap.mine.active .board-frame { box-shadow: 0 0 0 2px rgba(226, 59, 46, .6), 0 12px 30px rgba(0, 0, 0, .45); }
.labels { display: flex; color: #9fbcdb; font: 12px var(--stencil); }
.labels span { display: grid; place-items: center; }
.labels.cols { grid-column: 2; grid-row: 1; }
.labels.cols span { width: var(--cell); }
.labels.rows { grid-column: 1; grid-row: 2; flex-direction: column; }
.labels.rows span { height: var(--cell); }
.corner { grid-column: 1; grid-row: 1; }
.rivet {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e9eef3, #8c9aa8 60%, #4c5968);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .6);
}
.rivet.tl { top: 6px; left: 6px; } .rivet.tr { top: 6px; right: 6px; }
.rivet.bl { bottom: 6px; left: 6px; } .rivet.br { bottom: 6px; right: 6px; }

.board { position: relative; grid-column: 2; grid-row: 2; border-radius: 4px; }
.board.can-fire { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.5' stroke-width='4'%3E%3Ccircle cx='16' cy='16' r='9'/%3E%3Cpath d='M16 2v8M16 22v8M2 16h8M22 16h8'/%3E%3C/g%3E%3Cg fill='none' stroke='%23f2b33d' stroke-width='2'%3E%3Ccircle cx='16' cy='16' r='9'/%3E%3Cpath d='M16 2v8M16 22v8M2 16h8M22 16h8'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='1.6' fill='%23ff5a3c'/%3E%3C/svg%3E") 16 16, crosshair; }
.layer { position: absolute; inset: 0; pointer-events: none; }
.layer:not(.layer-cells) { z-index: 2; }
.layer-cells { display: grid; }
.layer-fx { overflow: visible; z-index: 5; }

.cell { width: var(--cell); height: var(--cell); position: relative; }
.cell.sea {
  background:
    radial-gradient(circle, rgba(6, 20, 38, .55) 0 11%, rgba(6, 20, 38, .2) 14%, transparent 17%) 0 0 / var(--cell) var(--cell),
    radial-gradient(ellipse at 50% 30%, #2f6ea9, #22568c 50%, #1a416d) 0 0 / var(--bw) var(--bh);
  box-shadow: inset 0 0 0 .5px rgba(6, 20, 38, .35);
}
.layer-land { z-index: 2; }
.particles { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1400; }
.ocean { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 4px; }
.board.gl .cell.sea { background: none; box-shadow: none; }
.board.gl .layer-land { display: none; }   /* đảo được vẽ luôn trong shader */
.isle {
  position: absolute; width: var(--cell); height: var(--cell); display: grid; place-items: center;
  background:
    radial-gradient(circle, rgba(255, 255, 255, .12) 0 1.2px, transparent 2px) 0 0 / 11px 13px,
    radial-gradient(circle, rgba(25, 55, 20, .22) 0 1.8px, transparent 2.6px) 0 0 / 17px 15px,
    radial-gradient(ellipse at 40% 30%, #9ccb6c, #6c9d4b 55%, #4e7b37) 0 0 / var(--bw) var(--bh);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25));
}
.layer-shore { z-index: 1; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.layer-shore > div { position: absolute; inset: 0; background-size: 100% 100%; }
.shore-far { animation: wave-in 4.2s ease-in-out infinite; }
.shore-near { animation: wave-hit 4.2s ease-in-out infinite; }

/* Mặt nước: 2 lớp ánh sáng lăn tăn trôi ngược chiều + một vùng sáng lớn dập dềnh */
.layer-water { z-index: 1; overflow: hidden; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.water { position: absolute; will-change: transform; }
.water.c1 { inset: -256px; background-size: 256px 256px; opacity: .2; mix-blend-mode: screen; animation: drift1 26s linear infinite; }
.water.c2 { inset: -256px; background-size: 192px 192px; opacity: .14; mix-blend-mode: screen; animation: drift2 19s linear infinite; }
.glint {
  position: absolute; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, .9), 0 0 0 0 rgba(255, 255, 255, 0);
  animation: glint 5s ease-in-out infinite; opacity: 0;
}
.water.swell {
  inset: -35%;
  background:
    radial-gradient(ellipse 34% 26% at 32% 38%, rgba(140, 200, 255, .16), transparent 70%),
    radial-gradient(ellipse 30% 24% at 70% 66%, rgba(8, 28, 56, .28), transparent 70%),
    radial-gradient(ellipse 26% 20% at 62% 24%, rgba(140, 200, 255, .10), transparent 70%);
  animation: swell 14s ease-in-out infinite alternate;
}
.palm { font-size: calc(var(--cell) * .55); filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .4)); }

/* Tàu */
.ship { position: absolute; filter: drop-shadow(3px 5px 4px rgba(0, 0, 0, .5)); transition: filter .2s; }
.ship-inner { position: absolute; left: 0; top: 0; }
.layer-ships .ship { animation: ship-bob 5s ease-in-out infinite; }
/* bọt nước ôm quanh thân tàu */
.layer-ships .ship::before {
  content: ''; position: absolute; inset: 14% -4%; border-radius: 50%; z-index: -1;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(255, 255, 255, .38) 64%, rgba(255, 255, 255, 0) 76%);
  animation: hull-foam 3.4s ease-in-out infinite; animation-delay: inherit;
}
.layer-ships .ship.vertical::before { inset: -4% 14%; }
/* tàu chìm: nghiêng, ngập nửa thân */
.layer-ships .ship.sunk { animation: none; transform: rotate(-4deg) scale(.96); }
.layer-ships .ship.sunk::before { display: none; }
.layer-ships .ship.sunk::after {
  content: ''; position: absolute; inset: 12% -2%; border-radius: 45%; pointer-events: none;
  background: linear-gradient(100deg, rgba(25, 75, 125, 0) 20%, rgba(25, 75, 125, .55) 55%, rgba(25, 75, 125, .75));
}
.layer-ships .ship.vertical.sunk::after { inset: -2% 12%; background: linear-gradient(190deg, rgba(25, 75, 125, 0) 20%, rgba(25, 75, 125, .55) 55%, rgba(25, 75, 125, .75)); }
.ship-inner svg { width: 100%; height: 100%; display: block; }
.ship.vertical .ship-inner { transform: rotate(90deg) translateY(-100%); transform-origin: top left; }
.ship.sunk .ship-inner { filter: sepia(1) saturate(2.2) hue-rotate(-25deg) brightness(.5); }
.ship.sunk { filter: drop-shadow(0 0 6px rgba(226, 59, 46, .55)); }
.ship.ghosted, .hover-ghost { opacity: .55; }
.placing .layer-ships .ship { pointer-events: auto; cursor: grab; }
.placing .layer-ships .ship:hover { filter: drop-shadow(0 0 6px var(--accent)) drop-shadow(0 3px 3px rgba(0, 0, 0, .55)); }
.drag-ghost { position: fixed !important; pointer-events: none; z-index: 1000; opacity: .9; }

/* Cọc trúng/trượt */
.peg { position: absolute; width: var(--cell); height: var(--cell); display: grid; place-items: center; font-size: calc(var(--cell) * .55); }
.peg::before { content: ''; position: absolute; width: 40%; height: 40%; border-radius: 50%; }
.peg.miss::before {
  background: radial-gradient(circle at 35% 30%, #fff, #dde2e7 55%, #97a1ab);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .55);
}
.peg.hit::before {
  width: 46%; height: 46%;
  background: radial-gradient(circle at 35% 30%, #ff9a8a, var(--red) 55%, #871810);
  box-shadow: 0 0 10px rgba(255, 80, 50, .8), 0 2px 3px rgba(0, 0, 0, .55);
  animation: glow 1.8s ease-in-out infinite;
}
.peg.supply::before { width: 70%; height: 70%; background: rgba(242, 179, 61, .25); box-shadow: 0 0 0 2px var(--accent); }
.peg.new { animation: peg-in .35s cubic-bezier(.3, 1.5, .6, 1) backwards; }
.peg:nth-child(3n) .radar-mark span {
  background: #1f9d68; color: white; font-weight: 800; min-width: 26px; height: 26px; border-radius: 13px;
  display: grid; place-items: center; box-shadow: 0 0 10px rgba(60, 220, 140, .8); font-size: 15px;
}
.radar-mark.empty { border-color: rgba(160, 190, 220, .6); background: rgba(160, 190, 220, .08); }
.radar-mark.empty span { background: #4d6680; box-shadow: none; }
.radar-mark.new { animation: fade-in .4s backwards; }

/* Xem trước khi ngắm / đặt tàu */
.pv { position: absolute; width: var(--cell); height: var(--cell); border-radius: 3px; }
.pv.ok { background: rgba(76, 195, 138, .35); box-shadow: inset 0 0 0 2px rgba(76, 195, 138, .9); }
.pv.bad { background: rgba(226, 59, 46, .35); box-shadow: inset 0 0 0 2px rgba(226, 59, 46, .9); }
.pv.aim { background: rgba(242, 179, 61, .28); box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 12px rgba(242, 179, 61, .6); }
.pv.scan { background: rgba(90, 230, 160, .25); box-shadow: inset 0 0 0 2px rgba(90, 230, 160, .9); }
.reticle { position: absolute; width: var(--cell); height: var(--cell); display: grid; place-items: center; z-index: 3; }
.reticle svg {
  width: 150%; height: 150%; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(242, 179, 61, .8)); animation: reticle 3s linear infinite;
}
.reticle .dot { fill: #ff5a3c; stroke: none; }
.reticle.bad svg { stroke: #ff5a47; filter: drop-shadow(0 0 4px rgba(255, 90, 71, .8)); animation: none; opacity: .8; }
.reticle.scan svg { stroke: #5ae6a0; filter: drop-shadow(0 0 4px rgba(90, 230, 160, .8)); }
.labels span { transition: color .12s, transform .12s; }
.labels span.hl { color: var(--accent); transform: scale(1.35); text-shadow: 0 0 8px rgba(242, 179, 61, .8); }

/* =================== HIỆU ỨNG =================== */
.fx { position: absolute; transform: translate(-50%, -50%); pointer-events: none; animation-fill-mode: both; }
.fx i { position: absolute; left: 50%; top: 50%; border-radius: 50%; animation-delay: var(--d); animation-fill-mode: both; }
/* bắn trượt */
.splash { width: 0; height: 0; }
.splash b, .splash i { position: absolute; left: 0; top: 0; animation-delay: var(--d); animation-fill-mode: both; }
.splash .column {
  width: calc(var(--cell) * .42); height: calc(var(--cell) * 1.3); margin-left: calc(var(--cell) * -.21);
  border-radius: 50% 50% 40% 40%; transform-origin: 50% 100%; top: calc(var(--cell) * -1.3);
  background: linear-gradient(rgba(255, 255, 255, .95), rgba(190, 235, 255, .8) 55%, rgba(120, 200, 255, 0));
  animation: column .7s cubic-bezier(.2, .8, .4, 1);
  animation-delay: var(--d);
}
.splash .ripple {
  width: calc(var(--cell) * 1.1); height: calc(var(--cell) * .8); margin: calc(var(--cell) * -.4) 0 0 calc(var(--cell) * -.55);
  border-radius: 50%; border: 2px solid rgba(220, 245, 255, .9); animation: ripple2 1.1s ease-out;
  animation-delay: var(--d);
}
.splash .ripple.r1 { animation-delay: calc(var(--d) + 220ms); border-width: 1.5px; }
.splash .drop {
  width: 5px; height: 5px; margin: -2.5px; border-radius: 50%; background: #e4f6ff;
  animation: drop 0.8s cubic-bezier(.25, .6, .5, 1);
  animation-delay: var(--d);
}

/* trúng */
.boom { width: 0; height: 0; }
.boom b, .boom i { position: absolute; left: 0; top: 0; border-radius: 50%; animation-delay: var(--d); animation-fill-mode: both; }
.boom .flash {
  width: calc(var(--cell) * 2.2); height: calc(var(--cell) * 2.2); margin: calc(var(--cell) * -1.1);
  background: radial-gradient(circle, #fff 0%, rgba(255, 244, 200, .9) 25%, rgba(255, 200, 80, 0) 65%);
  animation: flash .28s ease-out;
  animation-delay: var(--d);
}
.boom .ball {
  width: calc(var(--cell) * 1.5); height: calc(var(--cell) * 1.5); margin: calc(var(--cell) * -.75);
  background: radial-gradient(circle, #fffbe0 0%, #ffd044 22%, #ff7a1f 45%, #c7301a 62%, rgba(90, 20, 10, 0) 72%);
  animation: ball .8s cubic-bezier(.2, .9, .4, 1);
  animation-delay: var(--d);
}
.boom .ring {
  width: calc(var(--cell) * 1.2); height: calc(var(--cell) * 1.2); margin: calc(var(--cell) * -.6);
  border: 3px solid rgba(255, 236, 190, .85); animation: shock .55s ease-out;
  animation-delay: var(--d);
}
.boom .deb {
  width: 5px; height: 3px; margin: -1.5px -2.5px; border-radius: 1px; background: #2a2f35;
  box-shadow: 0 0 2px rgba(255, 120, 40, .8); animation: debris .9s cubic-bezier(.15, .7, .4, 1);
  animation-delay: var(--d);
}
.boom .spk { width: 4px; height: 4px; margin: -2px; background: #ffe27a; box-shadow: 0 0 6px 2px #ff9a2a; animation: spark2 .6s ease-out; animation-delay: var(--d); }
.boom .smk {
  width: calc(var(--cell) * .9); height: calc(var(--cell) * .9); margin: calc(var(--cell) * -.45);
  background: radial-gradient(circle, rgba(60, 60, 64, .75), rgba(40, 40, 44, 0) 70%);
  animation: smoke2 1.8s ease-out; animation-delay: calc(var(--d) + var(--sd));
}
.boom.big .ball { width: calc(var(--cell) * 2.3); height: calc(var(--cell) * 2.3); margin: calc(var(--cell) * -1.15); }
.boom.big .ring { border-width: 4px; }
.float-text {
  font: calc(var(--cell) * .42) var(--stencil); color: #ffb347; white-space: nowrap; letter-spacing: 1px;
  text-shadow: 0 2px 0 #5a1d08, 0 0 10px rgba(255, 120, 40, .7); animation: float-text 1.5s ease-out both; z-index: 8;
}
.float-text.sunk { font-size: calc(var(--cell) * .6); color: #ff5a47; text-shadow: 0 2px 0 #3d0a05, 0 0 16px rgba(255, 60, 40, .9); }
.float-text.good { color: #8ff0b8; text-shadow: 0 2px 0 #0b3a24, 0 0 10px rgba(80, 230, 150, .6); }

/* đạn bay */
.shell {
  position: fixed; left: 0; top: 0; z-index: 2100; pointer-events: none;
  width: 16px; height: 7px; margin: -3.5px 0 0 -8px; border-radius: 40% 60% 60% 40%;
  background: linear-gradient(90deg, #6b5b3e, #d9c9a3 60%, #fff4d6);
  box-shadow: 0 0 10px 3px rgba(255, 190, 90, .75);
}
.shell.big { width: 22px; height: 10px; margin: -5px 0 0 -11px; }
.trail { position: fixed; z-index: 2090; pointer-events: none; border-radius: 50%; animation: trail .8s ease-out forwards; }
.trail.smoke { width: 9px; height: 9px; margin: -4.5px; background: radial-gradient(circle, rgba(235, 235, 240, .75), rgba(200, 200, 210, 0) 70%); }
.trail.contrail { width: 7px; height: 7px; margin: -3.5px; background: radial-gradient(circle, rgba(255, 255, 255, .8), transparent 70%); }
.trail.bubble { position: absolute; width: 6px; height: 6px; margin: -3px; border: 1px solid rgba(220, 245, 255, .8); background: transparent; }
.plane { position: fixed; left: 0; top: 0; z-index: 2100; pointer-events: none; filter: drop-shadow(0 14px 6px rgba(0, 0, 0, .35)); }
.plane svg { width: 100%; height: 100%; margin: -50% 0 0 -50%; display: block; }
.torpedo {
  position: absolute; left: 0; top: 0; width: calc(var(--cell) * .55); height: 7px; margin: -3.5px 0 0 calc(var(--cell) * -.27);
  border-radius: 40% 60% 60% 40%; background: linear-gradient(#5a6570, #1f262c); box-shadow: 0 0 6px rgba(160, 220, 255, .6); z-index: 6;
}

.sparkle { font-size: var(--cell); animation: float-up 1.3s ease-out both; }
.radar-sweep {
  width: calc(var(--cell) * 3.2); height: calc(var(--cell) * 3.2); border-radius: 50%;
  border: 2px solid rgba(90, 230, 160, .8);
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(90, 230, 160, .65) 100%);
  animation: sweep 1.4s linear both;
}
.shake { animation: shake .5s; }
.shake-soft { animation: shake-soft .22s; }

.float-emoji { position: fixed; z-index: 2000; pointer-events: none; animation: emoji-up 2.4s ease-out both; }
.confetti { position: fixed; top: -20px; width: 9px; height: 14px; z-index: 1900; pointer-events: none; animation: fall linear both; border-radius: 2px; }

.toasts { position: fixed; top: 124px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 3000; align-items: center; pointer-events: none; }
.toast {
  background: #173049; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px;
  padding: 10px 16px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: toast-in .3s ease-out; transition: opacity .4s, transform .4s;
}
.toast.error, .toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(-10px); }

/* =================== PHÒNG CHỜ =================== */
.lobby { max-width: 1060px; margin: 0 auto; }
.lobby-start {
  position: sticky; bottom: -30px; z-index: 5; margin: 0 -22px -30px; padding: 14px 22px 26px; text-align: center;
  background: linear-gradient(transparent, rgba(10, 22, 36, .92) 38%);
}
.lobby-start .btn.huge { margin: 0 auto; }
.lobby-start p { margin: 8px 0 0; }
.seats { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 6px 0 22px; }
.seat {
  width: 230px; padding: 18px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.seat.me { border-color: var(--accent); box-shadow: 0 0 20px rgba(242, 179, 61, .15); }
.seat.empty { border-style: dashed; opacity: .7; }
.seat.empty .seat-avatar { animation: bob 1.6s ease-in-out infinite; }
.seat-avatar {
  font-size: 46px; width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #24466b, #122840); border: 3px solid #2f5580;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, .45);
}
.seat.me .seat-avatar { border-color: var(--accent); box-shadow: inset 0 3px 10px rgba(0, 0, 0, .45), 0 0 18px rgba(242, 179, 61, .35); }
.seat-name { font-size: 19px; font-weight: 800; margin-top: 4px; }
.seat-status { color: var(--muted); font-size: 13px; }
.vs { font: 44px var(--stencil); color: var(--accent); text-shadow: 0 3px 0 #6b4606; }
.section-title { font: 20px var(--stencil); letter-spacing: 1.5px; margin: 10px 0 12px; }

.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.map-card {
  display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.map-card:hover { transform: translateY(-2px); border-color: #3d6792; }
.map-card.flash { animation: card-flash 1s ease-out; }
.hr-map > span { display: flex; flex-direction: column; line-height: 1.25; }
.hr-map small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.map-card.active { border-color: var(--accent); box-shadow: 0 0 18px rgba(242, 179, 61, .25); background: #1a3250; }
.minimap { display: grid; gap: 1px; width: 76px; flex: none; }
.minimap i { aspect-ratio: 1; border-radius: 1px; }
.minimap .s { background: #2c62a0; }
.minimap .l { background: #74a553; }
.map-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.map-info b { font-size: 15px; }
.map-info span { font-size: 12.5px; color: #c3d3e3; }
.map-info small { font-size: 11.5px; color: var(--muted); }

.lobby-options { margin-top: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 16px; }
.switch input { display: none; }
.switch .slider { width: 46px; height: 26px; border-radius: 13px; background: #3a4f66; position: relative; transition: background .2s; flex: none; }
.switch .slider::after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: white; top: 3px; left: 3px; transition: left .2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { left: 23px; }
.weapon-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px 20px; margin-top: 14px; transition: opacity .2s; }
.weapon-list.off { opacity: .35; }
.weapon-info { display: flex; gap: 10px; align-items: flex-start; }
.wi-icon { font-size: 24px; width: 32px; text-align: center; flex: none; }
.weapon-info p { margin: 2px 0 0; font-size: 12.5px; color: #c3d3e3; }
.weapon-info small { color: var(--muted); }
.note { grid-column: 1 / -1; margin: 4px 0 0; font-size: 12.5px; color: var(--accent); }

/* =================== ĐẶT TÀU =================== */
.phase-head { text-align: center; margin-bottom: 16px; }
.phase-head h2 { font: 24px var(--stencil); letter-spacing: 1.5px; }
.phase-head p { color: var(--muted); margin: 6px 0 0; }
.placement { display: flex; gap: 28px; justify-content: center; align-items: flex-start; }
.place-side { width: 290px; display: flex; flex-direction: column; gap: 12px; }
.dock { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.dock-title { font: 15px var(--stencil); letter-spacing: 1px; color: var(--muted); padding: 0 4px 4px; }
.dock-item { display: flex; align-items: center; gap: 12px; padding: 4px 8px; border-radius: 8px; border: 2px solid transparent; transition: background .15s; }
.dock-item:hover { background: var(--panel2); }
.dock-item.selected { border-color: var(--accent); background: #1d3653; }
.dock-item.placed .dock-ship { opacity: .35; }
.dock-ship { position: relative; flex: none; cursor: grab; touch-action: none; }
.dock-label { display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
.dock-label span { color: var(--muted); font-size: 12px; }
.place-tools { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.place-tools .btn { padding: 8px 4px; font-size: 13px; }
.opp-status { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.opp-status.done { border-color: var(--green); }
.wait-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.wait-card b { font-size: 18px; margin-top: 14px; }
.wait-card p { margin: 2px 0 14px; color: var(--muted); }
.sonar { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.sonar span {
  font-size: 40px; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: radial-gradient(circle at 50% 35%, #24466b, #122840); border: 2px solid rgba(90, 230, 160, .7);
}
.sonar i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(90, 230, 160, .6); animation: sonar-ping 2.4s ease-out infinite; }
.sonar i:nth-child(2) { animation-delay: .8s; }
.sonar i:nth-child(3) { animation-delay: 1.6s; }
.checklist { list-style: none; padding: 0; margin: 0; text-align: left; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.checklist li::before { content: '○'; display: inline-block; width: 20px; color: var(--muted); }
.checklist li.done::before { content: '✓'; color: var(--green); font-weight: 800; }
.checklist li:not(.done) { color: var(--muted); }

/* =================== CHIẾN ĐẤU =================== */
.battle-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.status-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 30px; padding: 7px 26px 7px 10px; font-size: 16px;
  display: flex; align-items: center; gap: 8px;
}
.sb-turn-av {
  font-size: 20px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg2); border: 2px solid var(--line);
}
.status-bar.mine .sb-turn-av { border-color: var(--accent); }
.dots i { font-style: normal; animation: blink 1.4s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
.status-bar.mine { border-color: var(--accent); box-shadow: 0 0 22px rgba(242, 179, 61, .3); animation: pulse-glow 1.8s ease-in-out infinite; }
.status-bar.win { border-color: var(--green); color: #9ff0c9; font-weight: 700; }
.status-bar.lose { border-color: var(--red); color: #ffb0a8; font-weight: 700; }
.status-bar .warn { color: #ffb0a8; }
.battle { display: flex; gap: 40px; justify-content: center; align-items: flex-start; }
.fleet-status { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; max-width: 520px; }
.fleet-chip {
  display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 7px; font-size: 11.5px;
}
.fleet-chip .bars { display: flex; gap: 2px; }
.fleet-chip .bars i { width: 7px; height: 9px; background: #4b6a8a; border-radius: 1px; }
.fleet-chip .bars i.dmg { background: var(--red); }
.fleet-chip.sunk { opacity: .5; }
.fleet-chip.sunk .fc-name { text-decoration: line-through; }

.weapons-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.weapon {
  width: 96px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; position: relative;
  transition: transform .12s, border-color .15s, background .15s;
}
.weapon:hover:not(:disabled) { transform: translateY(-2px); border-color: #3d6792; }
.weapon.active { border-color: var(--accent); background: #2a3a2e; background: linear-gradient(#3a3322, #2a2718); box-shadow: 0 0 16px rgba(242, 179, 61, .3); }
.weapon:disabled { opacity: .4; cursor: not-allowed; }
.weapon.lost .w-icon { filter: grayscale(1); }
.weapon.lost { border-style: dashed; }
.weapon.lost:disabled { opacity: .8; }
.weapon.lost .w-badge { color: inherit; }
.w-name small { display: block; font-size: 10px; font-weight: 600; color: #ff9f94; line-height: 1.1; }
.weapon.empty .w-badge { color: var(--muted); }
.w-gift {
  position: absolute; top: -8px; left: -6px; font-size: 10.5px; font-weight: 800; padding: 1px 5px; border-radius: 8px;
  background: linear-gradient(#ffd173, var(--accent2)); color: #1c1405; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.w-icon { font-size: 24px; line-height: 1.2; }
.w-name { font-size: 12px; font-weight: 600; }
.w-badge { position: absolute; top: 4px; right: 6px; font-size: 11px; font-weight: 800; color: var(--accent); }
.weapon.rotate { width: 80px; }
.weapon[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translate(-50%, 6px);
  width: 230px; padding: 9px 12px; border-radius: 10px; white-space: pre-line; text-align: left;
  background: #0b1a2c; border: 1px solid var(--line); box-shadow: 0 10px 24px rgba(0, 0, 0, .5);
  font-size: 12.5px; font-weight: 500; line-height: 1.45; color: var(--text);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 20;
}
.weapon[data-tip]:hover::after { opacity: 1; transform: translate(-50%, 0); }
.battle-actions { display: flex; gap: 10px; }

/* =================== HỘP THOẠI =================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(3, 10, 20, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 1500; animation: fade-in .2s;
}
.modal {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px; max-width: 560px; width: calc(100vw - 32px); max-height: 92vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6); animation: pop-in .25s cubic-bezier(.3, 1.4, .6, 1);
}
.wide .modal { max-width: 1240px; }
.modal-close { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--text); }
.locked .modal-close { display: none; }

.profile { display: flex; flex-direction: column; gap: 14px; }
.profile-hero {
  position: relative; height: 120px; margin: -26px -26px 0; border-radius: 18px 18px 0 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #2a5285, #13283f 75%);
  display: grid; place-items: center;
}
.hero-anchor { width: 64px; height: 64px; color: var(--accent); filter: drop-shadow(0 3px 0 #6b4606) drop-shadow(0 0 18px rgba(242, 179, 61, .35)); animation: bob 2.4s ease-in-out infinite; }
.wave { position: absolute; left: 0; width: 200%; height: 26px; background-repeat: repeat-x; background-size: 50% 100%; }
.wave.w1 { bottom: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20' preserveAspectRatio='none'%3E%3Cpath d='M0 10 Q15 0 30 10 T60 10 T90 10 T120 10 V20 H0z' fill='%23244a73'/%3E%3C/svg%3E"); animation: wave-x 7s linear infinite; opacity: .9; }
.wave.w2 { bottom: -6px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20' preserveAspectRatio='none'%3E%3Cpath d='M0 10 Q15 0 30 10 T60 10 T90 10 T120 10 V20 H0z' fill='%2313283f'/%3E%3C/svg%3E"); animation: wave-x 4.5s linear infinite reverse; }
.profile-sub { margin: -6px 0 0; text-align: center; color: var(--muted); }
.profile h2 { text-align: center; font: 24px var(--stencil); letter-spacing: 1px; }
.profile label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.profile input {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 16px; user-select: text;
}
.profile input:focus { outline: none; border-color: var(--accent); }
.avatar-label { font-weight: 600; }
.avatars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.av { background: var(--bg2); border: 2px solid transparent; border-radius: 10px; font-size: 22px; padding: 4px 0; cursor: pointer; }
.av:hover { border-color: var(--line); }
.av.active { border-color: var(--accent); background: #2a2718; }

.result { text-align: center; padding: 10px 0; }
.result-hero { position: relative; height: 120px; display: grid; place-items: center; }
.result-icon { font-size: 76px; position: relative; z-index: 1; animation: bob 1.6s ease-in-out infinite; }
.rays {
  position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background: repeating-conic-gradient(rgba(242, 179, 61, .35) 0 9deg, transparent 9deg 24deg);
  mask: radial-gradient(circle, #000 20%, transparent 68%); -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%);
  animation: spin 14s linear infinite;
}
.result-icon.sinking { animation: sink 3.2s ease-in-out infinite; }
.bubbles { position: absolute; inset: 0; }
.bubbles i {
  position: absolute; bottom: 20px; left: 50%; width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid rgba(170, 220, 255, .7); animation: bubble 2.6s ease-in infinite;
}
.bubbles i:nth-child(2) { margin-left: -24px; animation-delay: .7s; }
.bubbles i:nth-child(3) { margin-left: 20px; animation-delay: 1.3s; width: 6px; height: 6px; }
.bubbles i:nth-child(4) { margin-left: -8px; animation-delay: 1.9s; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 4px; }
.result-stats div { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; display: flex; flex-direction: column; }
.result-stats b { font: 24px var(--stencil); color: var(--accent); }
.result.lose .result-stats b { color: #9fbcdb; }
.result-stats span { font-size: 11.5px; color: var(--muted); }
.result h1 { font: 50px var(--stencil); letter-spacing: 3px; margin: 6px 0; }
.result.win h1 { color: var(--accent); text-shadow: 0 3px 0 #6b4606, 0 0 30px rgba(242, 179, 61, .4); }
.result.lose h1 { color: #ff7b6e; }
.result p { font-size: 16px; color: #c3d3e3; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.history h2 { font: 24px var(--stencil); letter-spacing: 1px; text-align: center; margin-bottom: 14px; }
.h2h { display: flex; justify-content: center; align-items: center; gap: 22px; }
.h2h div { display: flex; flex-direction: column; align-items: center; min-width: 110px; }
.h2h em { font-style: normal; font-size: 34px; margin-bottom: 4px; }
.h2h b { font: 52px var(--stencil); color: var(--accent); line-height: 1; }
.h2h span { font-weight: 700; }
.h2h > i { font: 36px var(--stencil); color: var(--muted); font-style: normal; }
.history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.history-row {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 14px; align-items: center;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.hr-map { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.hr-players i { color: var(--muted); font-style: normal; margin: 0 6px; }
.hr-meta { color: var(--muted); font-size: 12.5px; }


/* =================== KIỂU CHƠI =================== */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.section-head .section-title { margin: 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; cursor: pointer;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 12px 10px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.mode-card:hover { transform: translateY(-2px); border-color: #3d6792; }
.mode-card.active { border-color: var(--accent); background: #1a3250; box-shadow: 0 0 18px rgba(242, 179, 61, .25); }
.mode-icon { font-size: 30px; line-height: 1.1; }
.mode-card b { font-size: 14.5px; }
.mode-card small { font-size: 11.5px; color: #b6c8da; line-height: 1.35; }
.switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.switch > span:last-child { display: flex; flex-direction: column; }
.switch small { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.switch.disabled { opacity: .5; cursor: not-allowed; }
.lobby-summary {
  display: inline-flex; gap: 8px; align-items: center; margin-bottom: 10px; padding: 5px 14px; border-radius: 20px;
  background: rgba(8, 20, 34, .8); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600;
}
.lobby-summary i { color: var(--muted); font-style: normal; }

/* thanh trạng thái trận đấu */
.status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mode-chip {
  padding: 6px 12px; border-radius: 16px; font-size: 12.5px; font-weight: 700; position: relative;
  background: rgba(8, 20, 34, .7); border: 1px solid var(--line); color: #cfe0f1;
}
.mode-chip[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 0; width: 240px; z-index: 30;
  background: #0b1a2c; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-weight: 500; line-height: 1.4;
}
.streak { color: #ffb347; }
.combo {
  font: 15px var(--stencil); color: #1c1405; background: linear-gradient(#ffcf5a, #f08a1c); border-radius: 12px; padding: 2px 9px;
  animation: pop-in .3s cubic-bezier(.3, 1.6, .6, 1);
}
.combo.bad { font: 600 12px 'Be Vietnam Pro', sans-serif; background: rgba(226, 59, 46, .25); color: #ffb0a8; }
.turn-timer {
  position: relative; width: min(560px, 90%); height: 14px; border-radius: 7px; overflow: hidden;
  background: rgba(8, 20, 34, .8); border: 1px solid var(--line); margin-top: -4px;
}
.turn-timer .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #3a8fd8, #5aa9ff); transition: width .1s linear; }
.turn-timer.mine .fill { background: linear-gradient(90deg, #d9901c, var(--accent)); }
.turn-timer.urgent .fill { background: linear-gradient(90deg, #b3261b, #ff5a47); animation: pulse .5s infinite; }
.turn-timer span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; letter-spacing: .5px; }

/* thuỷ lôi */
.sea-mine { position: absolute; width: var(--cell); height: var(--cell); display: grid; place-items: center; opacity: .85; }
.sea-mine i, .peg.mine::after {
  content: ''; width: 42%; height: 42%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7d8a96, #2b333b 60%, #111519);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .5);
}
.sea-mine i { position: relative; }
.sea-mine i::before {
  content: ''; position: absolute; inset: -30%; border-radius: 50%;
  background:
    linear-gradient(#2b333b, #2b333b) center / 16% 100% no-repeat,
    linear-gradient(#2b333b, #2b333b) center / 100% 16% no-repeat;
  z-index: -1;
}
.peg.mine::before { width: 70%; height: 70%; background: radial-gradient(circle, rgba(255, 90, 40, .55), transparent 70%); animation: glow 1.2s infinite; }
.peg.mine::after { position: absolute; }

/* loạt pháo */
.target-mark {
  position: absolute; width: var(--cell); height: var(--cell); display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px var(--accent); border-radius: 50%; animation: target-pulse 1s ease-in-out infinite;
  background: radial-gradient(circle, rgba(242, 179, 61, .25), transparent 70%);
}
.target-mark span {
  font: 11px var(--stencil); color: #1c1405; background: var(--accent); border-radius: 8px; min-width: 16px; height: 16px;
  display: grid; place-items: center; padding: 0 3px;
}
.fire-btn {
  align-self: stretch; min-width: 170px; padding: 0 18px; border-radius: 12px; cursor: pointer;
  font: 17px var(--stencil); letter-spacing: 1px; color: #1c1405; border: 2px solid #b87a12;
  background: linear-gradient(#ffd173, var(--accent2)); box-shadow: 0 0 20px rgba(242, 179, 61, .35);
}
.fire-btn:disabled { background: var(--panel); color: var(--muted); border-color: var(--line); box-shadow: none; cursor: not-allowed; font: 600 13px 'Be Vietnam Pro', sans-serif; letter-spacing: 0; }
.fire-btn:not(:disabled) { animation: cta-glow 1.6s ease-in-out infinite; }
.fog-reveal { animation: fog-reveal 1.6s ease-out both; z-index: 6; }

/* =================== DẢI CHỮ LỚN =================== */
.banner {
  position: fixed; left: 0; right: 0; top: 42%; z-index: 2200; pointer-events: none;
  display: grid; place-items: center; animation: banner-band 1.9s ease-in-out both;
}
.banner-inner {
  width: 100%; padding: 16px 0 14px; text-align: center;
  background: linear-gradient(90deg, transparent, rgba(10, 22, 36, .92) 18%, rgba(10, 22, 36, .92) 82%, transparent);
  border-top: 2px solid; border-bottom: 2px solid; border-image: linear-gradient(90deg, transparent, var(--accent), transparent) 1;
}
.banner.red .banner-inner { border-image: linear-gradient(90deg, transparent, var(--red), transparent) 1; }
.banner-title {
  font: 46px var(--stencil); letter-spacing: 6px; color: var(--accent);
  text-shadow: 0 3px 0 #6b4606, 0 0 30px rgba(242, 179, 61, .5); animation: banner-text 1.9s ease-in-out both;
}
.banner.red .banner-title { color: #ff6b5b; text-shadow: 0 3px 0 #6d1a12, 0 0 30px rgba(255, 90, 60, .5); }
.banner-sub { font-size: 15px; color: #c3d3e3; margin-top: 2px; animation: banner-text 1.9s ease-in-out both; }
.enter { animation: enter .35s ease-out; }

/* =================== KEYFRAMES =================== */
@keyframes banner-band {
  0% { opacity: 0; transform: scaleY(0); }
  12%, 82% { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(.6); }
}
@keyframes banner-text {
  0% { transform: translateX(-60px); opacity: 0; }
  18%, 78% { transform: none; opacity: 1; }
  100% { transform: translateX(60px); opacity: 0; }
}
@keyframes target-pulse { 50% { transform: scale(.86); } }
@keyframes fog-reveal { 0% { opacity: 0; transform: scale(1.6); } 15%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes card-flash { 0% { box-shadow: 0 0 0 6px rgba(242, 179, 61, .8); transform: scale(1.04); } }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sink {
  0%, 100% { transform: translateY(-6px) rotate(-8deg); }
  50% { transform: translateY(10px) rotate(-20deg); }
}
@keyframes bubble {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-90px) translateX(6px); opacity: 0; }
}
@keyframes sonar-ping { from { transform: scale(.55); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
@keyframes cta-glow { 50% { box-shadow: 0 2px 0 #9b6508, 0 0 34px rgba(242, 179, 61, .55); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
@keyframes glow { 50% { box-shadow: 0 0 16px rgba(255, 90, 50, 1), 0 2px 3px rgba(0, 0, 0, .55); } }
@keyframes pulse-glow { 50% { box-shadow: 0 0 34px rgba(242, 179, 61, .55); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { transform: scale(.9); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(-14px); opacity: 0; } }
@keyframes peg-in { from { transform: translateY(-26px) scale(1.8); opacity: 0; } }
@keyframes float-up {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  30% { transform: translate(-50%, -80%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -180%) scale(1); opacity: 0; }
}
@keyframes sweep {
  0% { transform: translate(-50%, -50%) rotate(0) scale(.6); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(720deg) scale(1); opacity: 0; }
}
@keyframes shake {
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -1px); }
}
@keyframes emoji-up {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  15% { transform: translate(-50%, -80%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -320px) scale(1); opacity: 0; }
}
@keyframes wave-x { to { transform: translateX(-50%); } }
@keyframes drift1 { to { transform: translate(256px, 256px); } }
@keyframes drift2 { to { transform: translate(-192px, 192px); } }
@keyframes swell { to { transform: translate(14%, 9%) rotate(4deg); } }
/* sóng từ ngoài (vòng xa) tiến vào, đập vào bờ (vòng sát bờ sáng lên) rồi rút */
@keyframes wave-in { 0% { opacity: 0; } 30% { opacity: .9; } 50%, 100% { opacity: 0; } }
@keyframes wave-hit { 0%, 30% { opacity: .25; } 52% { opacity: 1; } 100% { opacity: .25; } }
@keyframes column {
  0% { transform: scaleY(0) scaleX(.6); opacity: 0; }
  1% { opacity: 1; }
  45% { transform: scaleY(1) scaleX(1); opacity: 1; }
  100% { transform: scaleY(.2) scaleX(1.3); opacity: 0; }
}
@keyframes ripple2 { 0% { transform: scale(.2); opacity: 0; } 1% { opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }
@keyframes drop {
  0% { transform: rotate(var(--a)) translateY(0); opacity: 0; }
  1% { opacity: 1; }
  60% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--cell) * -1 * var(--h))); opacity: 0; }
}
@keyframes flash { 0% { transform: scale(.3); opacity: 0; } 1% { opacity: 1; } 100% { transform: scale(1.1); opacity: 0; } }
@keyframes ball {
  0% { transform: scale(.1); opacity: 0; }
  1% { opacity: 1; }
  35% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; filter: blur(3px); }
}
@keyframes shock { 0% { transform: scale(.2); opacity: 0; } 1% { opacity: 1; } 100% { transform: scale(2.4); opacity: 0; border-width: 1px; } }
@keyframes debris {
  0% { transform: rotate(var(--a)) translateY(0) rotate(0); opacity: 0; }
  1% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--cell) * -1.3 * var(--k))) rotate(var(--r)); opacity: 0; }
}
@keyframes spark2 {
  0% { transform: rotate(var(--a)) translateY(0) scale(1); opacity: 0; }
  1% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--cell) * -.9 * var(--k))) scale(.2); opacity: 0; }
}
@keyframes smoke2 {
  0% { transform: translate(0, 0) scale(.3); opacity: 0; }
  20% { opacity: .9; }
  100% { transform: translate(var(--dx), calc(var(--cell) * -1.2)) scale(1.9); opacity: 0; }
}
@keyframes float-text {
  0% { transform: translate(-50%, -30%) scale(.4); opacity: 0; }
  15% { transform: translate(-50%, -110%) scale(1.15); opacity: 1; }
  70% { transform: translate(-50%, -150%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -190%) scale(1); opacity: 0; }
}
@keyframes trail { from { transform: scale(.6); opacity: .9; } to { transform: scale(2.2); opacity: 0; } }
@keyframes shake-soft {
  33% { transform: translate(-2px, 1px); }
  66% { transform: translate(2px, -1px); }
}
@keyframes ship-bob {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  30% { transform: translate(0, -1px) rotate(.5deg); }
  65% { transform: translate(0, 1px) rotate(-.5deg); }
}
@keyframes hull-foam { 0%, 100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.04); } }
@keyframes glint { 0%, 70%, 100% { opacity: 0; transform: scale(.4); } 80% { opacity: .95; transform: scale(1.4); } 90% { opacity: .2; transform: scale(.6); } }
@keyframes reticle { to { transform: rotate(360deg); } }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); } }

/* Màn hình hẹp: thu gọn thanh bên */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 260px; }
  .sb-side { min-width: 0; }
  .sb-name { display: none; }
}
