:root {
  --paper: #f3ead3;
  --panel: #fffaf0;
  --ink: #1d1712;
  --muted: #6b6155;
  --line: #d9c9a3;
  --accent: #8b1e1e;
  --sea: #1c4e63;
  --vessel: #9b2226;
  --treasure: #a87400;
  --port: #1c6e63;
  --home: #3d405b;
  --good: #2d6a4f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
h1, h2, h3, .brand { font-family: Georgia, "Times New Roman", serif; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); margin: 0 0 .4em; color: var(--accent); }
h2 { font-size: 1.45rem; margin: 0 0 .6em; color: var(--accent); }
h3 { font-size: 1.15rem; margin: 1em 0 .4em; color: var(--sea); }
a { color: var(--sea); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px 48px; }

/* top bar */
.topbar { background: var(--sea); color: #fff; }
.topbar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding-top: 12px; padding-bottom: 12px; }
.brand { color: #fff; font-size: 1.5rem; font-weight: bold; text-decoration: none; }
.turninfo { font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 4px 12px; font-size: .9rem; }
.chip b { font-weight: 700; }

/* layout */
.layout { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 20px; }
@media (min-width: 980px) { .layout { grid-template-columns: minmax(0, 1.75fr) minmax(340px, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel.yourmove { border: 3px solid var(--accent); box-shadow: 0 0 0 4px rgba(139,30,30,.12); }
.panel.waiting { border-left: 6px solid var(--sea); }
.yourmove-tag { display: inline-block; background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 10px; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 8px; }
.muted { color: var(--muted); }
.flash { background: #fde8b0; border: 1px solid #e0b84a; padding: 12px 16px; border-radius: 8px; margin-top: 16px; }

/* buttons */
button, .btn {
  font: inherit; font-size: 1.05rem; min-height: 48px; padding: 10px 18px;
  border: none; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button.secondary, .btn.secondary { background: var(--muted); }
button:disabled { background: #b5ada3; cursor: not-allowed; }
button:not(:disabled):hover, .btn:hover { filter: brightness(1.12); }
.btnrow { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.btnrow.big button { min-width: 160px; font-size: 1.15rem; min-height: 60px; }

/* map card tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.tile {
  font: inherit; text-align: left; color: var(--ink); background: #fff; cursor: default;
  border: 3px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden;
  display: flex; flex-direction: column; min-height: 190px; width: 100%;
}
button.tile { cursor: pointer; transition: transform .08s, box-shadow .08s; }
button.tile:not(:disabled):hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.18); filter: none; }
.tile { align-items: stretch; justify-content: flex-start; }
.tile .band { display: block; width: 100%; text-align: left; color: #fff; padding: 8px 14px; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.tile .body { width: 100%; text-align: left; padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tile .name { font-family: Georgia, serif; font-size: 1.2rem; font-weight: bold; line-height: 1.25; }
.tile .stats { font-size: .98rem; }
.tile .who { margin-top: auto; font-size: .92rem; color: var(--muted); }
.tile .who b { color: var(--ink); }
.tile.vessel { border-color: var(--vessel); } .tile.vessel .band { background: var(--vessel); }
.tile.treasure { border-color: var(--treasure); } .tile.treasure .band { background: var(--treasure); }
.tile.port { border-color: var(--port); } .tile.port .band { background: var(--port); }
.tile.home { border-color: var(--home); } .tile.home .band { background: var(--home); }
.tile.taken { opacity: .55; }

/* choice cards (draft / purchases) */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.choice {
  font: inherit; text-align: left; color: var(--ink); background: #fff; border: 3px solid var(--sea);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 170px; cursor: pointer; width: 100%;
}
.choice:hover { box-shadow: 0 8px 18px rgba(0,0,0,.18); filter: none; }
.choice .type { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--sea); font-weight: 700; }
.choice .name { font-family: Georgia, serif; font-size: 1.2rem; font-weight: bold; }
.choice .dp { margin-top: auto; font-weight: 700; color: var(--good); }

/* action cards to play */
.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.actioncard { font: inherit; text-align: left; background: #fff; color: var(--ink); border: 2px solid var(--sea); border-radius: 10px; padding: 12px 14px; cursor: pointer; width: 100%; display: block; }
.actioncard b { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.actioncard:hover { background: #eef5f8; filter: none; }
.sabotage { border: 2px solid var(--sea); border-radius: 10px; padding: 12px 14px; background: #fff; }
.sabotage .btnrow button { min-height: 44px; font-size: .98rem; }

/* your ship */
.shipstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.shipstats .n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.shipstats .l { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hpbar { height: 12px; background: #e6dcc3; border-radius: 6px; overflow: hidden; margin: 12px 0 4px; }
.hpbar span { display: block; height: 100%; background: var(--good); }
.hpbar span.low { background: var(--vessel); }
.cardlist { list-style: none; padding: 0; margin: 0; }
.cardlist li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.cardlist li:last-child { border-bottom: none; }
.cardlist .t { color: var(--muted); font-size: .92rem; display: block; }
.tag { font-size: .75rem; background: #e6dcc3; border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

/* standings */
table.standings { width: 100%; border-collapse: collapse; }
table.standings th, table.standings td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
table.standings th { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
table.standings td.num, table.standings th.num { text-align: right; }
table.standings tr.you td { font-weight: 700; color: var(--good); background: #eef6f1; }

/* log */
.log { max-height: 560px; overflow-y: auto; font-size: .95rem; }
.log details { border-bottom: 1px solid var(--line); padding: 6px 0; }
.log summary { cursor: pointer; font-weight: 700; color: var(--sea); padding: 4px 0; }
.log p { margin: 3px 0 3px 4px; }
.ev-win { color: var(--good); font-weight: 600; }
.ev-sunk { color: var(--vessel); font-weight: 700; }
.ev-fight { color: #8a4b00; }
.ev-action { color: var(--sea); }
.ev-note { color: #5b3f8c; }
.ev-head { font-weight: 700; }
.ev-error { color: #fff; background: var(--vessel); padding: 4px 8px; border-radius: 6px; }

/* forms (home) */
.hero { padding: 28px 0 8px; }
.hero p { font-size: 1.15rem; max-width: 60ch; }
label.field { display: block; font-weight: 600; margin: 16px 0 6px; }
textarea, select, input[type=text] {
  font: inherit; font-size: 1.1rem; width: 100%; padding: 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { min-height: 150px; }
.formgrid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 800px) { .formgrid { grid-template-columns: 1.2fr 1fr; } }
.howto li { margin-bottom: 8px; }

/* invite */
.invite-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 800px) { .invite-row { grid-template-columns: 180px 1fr auto; align-items: center; } }
.invite-row input { font-size: 1rem; }
.invite-row .who { font-weight: 700; font-size: 1.15rem; }
