:root {
  --ink: #1d3344;
  --foam: rgba(255, 248, 238, 0.92);
  --line: rgba(92, 64, 40, 0.28);
  --brass: #c9853a;
  --sea: #1f6f86;
  --hit: #c4473a;
  --shadow: 0 18px 44px rgba(20, 28, 36, 0.32);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background:
    linear-gradient(180deg, rgba(16, 32, 44, 0.18), rgba(12, 24, 34, 0.38)),
    url("/assets/bg.jpg") center / cover no-repeat fixed;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: "Gowun Batang", serif; font-weight: 700; margin: 0; }
.hidden { display: none !important; }

#app { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.panel {
  width: min(440px, 100%);
  background: var(--foam);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.panel.wide { width: min(720px, 100%); }
.mark { width: 84px; height: 84px; object-fit: cover; border-radius: 50%; border: 3px solid #e6c48a; }
.eyebrow {
  margin: 10px 0 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--sea);
  font-weight: 700;
}
.lead, .me, .empty { color: #3e5160; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.92);
  border-radius: 12px;
  padding: 12px 14px;
}
.primary, .ghost {
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary { background: var(--sea); color: #f7fbfc; font-weight: 700; }
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost { background: transparent; border-color: var(--line); }
.row, .create-row, .actions { display: flex; gap: 10px; align-items: center; }
.row { justify-content: space-between; }
.actions.wrap { flex-wrap: wrap; }
.create-row { margin: 12px 0; }
.create-row input { flex: 1; margin: 0; }
.rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rooms li, .person, .player {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 252, 246, 0.78);
  border-radius: 14px;
  padding: 12px;
}
.rooms button { border: 0; background: var(--sea); color: #f7fbfc; border-radius: 999px; padding: 8px 14px; }
.rooms button:disabled { opacity: 0.45; }
.wait-players, .players, .fleet-list { display: grid; gap: 8px; margin: 14px 0; }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: -2px; }
.rules { margin: 8px 0 16px; }
.rules ul { margin: 8px 0 0; padding-left: 18px; color: #3e5160; }

.play {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  align-items: start;
}
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.boards.placing { grid-template-columns: minmax(0, 560px); }
.board-card, .side {
  background: var(--foam);
  border-radius: 24px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.board-card h3 { margin-bottom: 8px; font-size: 22px; }
.grid {
  display: grid;
  grid-template-columns: 18px repeat(10, minmax(0, 1fr));
  gap: 3px;
}
.axis {
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #6d5848;
  min-height: 16px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.38), transparent 42%),
    linear-gradient(180deg, rgba(126, 196, 208, 0.95), rgba(36, 112, 138, 0.95));
}
.cell.ship {
  background:
    linear-gradient(180deg, rgba(255, 236, 206, 0.35), transparent 40%),
    linear-gradient(180deg, #c49255, #6d4424);
}
.cell.hit {
  background:
    linear-gradient(180deg, rgba(255, 220, 200, 0.4), transparent 45%),
    linear-gradient(180deg, #e06a55, #9d2e28);
}
.cell.sunk {
  background:
    linear-gradient(180deg, #8a5a32, #3a2418);
  box-shadow: inset 0 0 0 2px #e0b06a;
}
.cell.miss::after {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  display: block;
  margin: auto;
  position: absolute;
  inset: 0;
}
.cell.hit::before,
.cell.hit::after {
  content: "";
  position: absolute;
  left: 20%;
  top: 48%;
  width: 60%;
  height: 2px;
  background: #fff6ea;
}
.cell.hit::before { transform: rotate(45deg); }
.cell.hit::after { transform: rotate(-45deg); }
.cell.pick { outline: 2px solid var(--brass); outline-offset: 1px; }
.cell.ghost { background: rgba(201, 133, 58, 0.72); }
.cell:not(:disabled):hover { filter: brightness(1.08); }
.cell:disabled { cursor: default; }

.status { min-height: 1.4em; font-weight: 700; margin: 8px 0; }
.ship-row {
  background: rgba(255, 252, 246, 0.78);
  border-radius: 12px;
  padding: 8px 10px;
}
.ship-row.now { box-shadow: inset 0 0 0 2px var(--brass); }
.dir p { margin: 0 0 8px; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; color: #3e5160; font-size: 13px; }
.legend .water { background: #3e90a4; }
.legend .wood { background: #8d5a30; }
.legend .hit { background: var(--hit); }
.legend .sunk { background: #3a2418; }
.player.turn { box-shadow: inset 0 0 0 2px var(--sea); }
.log { margin: 12px 0 0; padding-left: 18px; color: #3e5160; max-height: 180px; overflow: auto; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #8d3b32;
  color: #fff6ea;
  border-radius: 999px;
  padding: 10px 16px;
}

@media (max-width: 900px) {
  .play { grid-template-columns: 1fr; }
  .boards { grid-template-columns: 1fr; }
  #foeCard { order: -1; }
  #app { padding: 12px; }
}
