:root {
  --bg: #04101f; --panel: rgba(10, 30, 55, .72); --line: rgba(120, 190, 255, .22);
  --text: #dcecff; --muted: #86a6c7; --accent: #ffb13b; --accent2: #ff5a36; --ok: #4be08a;
  --title: 'Black Ops One', Impact, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #12406b 0%, #071d38 45%, var(--bg) 100%) fixed;
  color: var(--text); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow-x: hidden;
}
.sea-bg {
  position: fixed; inset: 0; pointer-events: none; opacity: .35; z-index: -1;
  background:
    repeating-linear-gradient(170deg, transparent 0 38px, rgba(120, 200, 255, .05) 38px 40px),
    repeating-linear-gradient(10deg, transparent 0 54px, rgba(120, 200, 255, .04) 54px 56px);
  animation: drift 30s linear infinite;
}
@keyframes drift { to { background-position: 400px 200px, -300px 150px; } }
.hidden { display: none !important; }

.btn {
  font: 600 14px system-ui, sans-serif; color: var(--text); cursor: pointer;
  background: linear-gradient(#1d4670, #13304f); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; transition: transform .1s, filter .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); box-shadow: 0 0 12px rgba(100, 180, 255, .3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { font-size: 17px; padding: 12px 28px; letter-spacing: .5px; }
.btn.primary { background: linear-gradient(#ffb13b, #e0681a); color: #1a0d00; border-color: #ffcf80; box-shadow: 0 4px 20px rgba(255, 140, 40, .35); }
.btn.primary.cancel { background: linear-gradient(#5b6f84, #3a4a5c); color: var(--text); border-color: var(--line); box-shadow: none; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.icon-btn.off { opacity: .4; text-decoration: line-through; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hint { color: var(--muted); font-size: 13px; text-align: center; max-width: 440px; margin: 8px auto 0; }

/* Home */
#home { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.hero { text-align: center; }
.logo {
  font-family: var(--title); font-weight: 400; font-size: clamp(64px, 16vw, 140px); margin: 0; letter-spacing: 6px;
  background: linear-gradient(#fff 10%, #9fd0ff 50%, #3b7fc0 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(80, 170, 255, .5)); animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px) rotate(-1deg); } }
.tag { color: var(--muted); font-size: 18px; margin: 0 0 32px; letter-spacing: 2px; text-transform: uppercase; }

/* Game */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(3, 12, 25, .6); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.mini-logo { font-family: var(--title); font-size: 26px; color: #9fd0ff; text-decoration: none; letter-spacing: 2px; }
.status { flex: 1; text-align: center; font-weight: 700; font-size: 17px; letter-spacing: .3px; transition: color .3s; }
.status.turn { color: var(--accent); text-shadow: 0 0 14px rgba(255, 170, 60, .6); animation: pulse 1.4s ease-in-out infinite; }
.status.wait { color: var(--muted); }
.status.win { color: var(--ok); } .status.lose { color: var(--accent2); }
@keyframes pulse { 50% { opacity: .65; } }

.share { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 12px 16px; background: rgba(255, 177, 59, .08); border-bottom: 1px solid rgba(255, 177, 59, .25); }
.share input { width: min(420px, 100%); background: #061527; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 14px ui-monospace, monospace; }

.boards { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; padding: 20px 16px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; width: min(492px, 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, .35); transition: box-shadow .3s, border-color .3s; }
.panel h2 { font-family: var(--title); font-weight: 400; margin: 0 0 10px; font-size: 20px; letter-spacing: 2px; text-align: center; color: #b9dcff; }
.panel.active { border-color: rgba(255, 177, 59, .7); box-shadow: 0 0 30px rgba(255, 150, 40, .3), 0 10px 40px rgba(0, 0, 0, .35); }
.panel.danger { border-color: rgba(255, 80, 60, .45); }
.cw { position: relative; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; touch-action: manipulation; }
#enemy { cursor: crosshair; }
.board-overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; border-radius: 10px; background: rgba(2, 10, 22, .55); backdrop-filter: blur(2px); font-weight: 700; font-size: 18px; color: var(--muted); }
.board-overlay:empty { display: none; }

.fleet { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.fleet span { display: inline-flex; align-items: center; gap: 5px; transition: opacity .3s; }
.fleet span.sunk { opacity: .5; text-decoration: line-through; color: var(--accent2); }
.pips { display: inline-flex; gap: 2px; }
.pips i { width: 8px; height: 8px; border-radius: 2px; background: #8ea3b6; }
.sunk .pips i { background: var(--accent2); }

.setup { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.dock { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.dock button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px; font-size: 12px; }
.dock button.sel { border-color: var(--accent); box-shadow: 0 0 10px rgba(255, 177, 59, .5); }
.dock button.placed { opacity: .45; }
.dock .pips i { width: 11px; height: 11px; }

.modal { position: fixed; inset: 0; background: rgba(0, 5, 15, .7); display: grid; place-items: center; z-index: 20; padding: 16px; animation: fade .4s; }
.modal-box { background: linear-gradient(#0f2b4b, #081a30); border: 1px solid var(--line); border-radius: 18px; padding: 28px 32px; text-align: center; max-width: 440px; width: 100%; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.modal-box h2 { font-family: var(--title); font-weight: 400; font-size: 48px; margin: 0 0 8px; letter-spacing: 3px; }
.modal-box h2.win { color: var(--ok); text-shadow: 0 0 30px rgba(75, 224, 138, .6); }
.modal-box h2.lose { color: var(--accent2); text-shadow: 0 0 30px rgba(255, 90, 54, .6); }
.modal-box p { color: var(--muted); margin: 0 0 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: #10304f; border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; transition: transform .35s; z-index: 30; font-weight: 600; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) {
  .top { gap: 8px; padding: 8px 12px; } .mini-logo { font-size: 20px; } .status { font-size: 14px; }
  .boards { padding: 12px 8px 30px; gap: 14px; } .panel { padding: 10px; }
}
