:root {
  --paper: #f6efe0;
  --card: #fffaf0;
  --ink: #1f2340;
  --ink-soft: #5b5f7a;
  --ink-faint: #8b8fa6;
  --line: #dccfb4;
  --line-strong: #bfae8a;
  --red: #b8362a;
  --red-soft: #f6dcd6;
  --gold: #c98a12;
  --gold-soft: #fbe9c4;
  --teal: #1e7f78;
  --teal-soft: #d8efe9;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0; }
h1 { font-size: 40px; letter-spacing: 0.06em; color: var(--red); }
h2 { font-size: 20px; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 8px; }
small, .soft { color: var(--ink-soft); font-size: 13px; }

#app { max-width: 1180px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

button {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button:where(:not(.mode-grid button)):hover:not(:disabled) { background: var(--gold-soft); }
button:disabled { color: var(--ink-faint); background: #f1eadb; cursor: not-allowed; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover:not(:disabled) { background: #9c2a20; }
button.small { padding: 4px 8px; font-size: 13px; }
button.on { background: var(--gold-soft); border-color: var(--gold); }

input[type="text"], input[type="number"], select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 10px;
}
input[type="number"] { width: 76px; }
label { display: block; margin-bottom: 10px; }
label.check { display: flex; gap: 8px; align-items: center; }

/* setup */
.setup { max-width: 560px; margin: 32px auto; }
.setup .tag { color: var(--ink-soft); margin: 4px 0 18px; }
.setup .row { display: flex; gap: 12px; flex-wrap: wrap; }
.setup .row label { flex: 1; min-width: 150px; }
.setup label span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.setup label.check span { display: inline; margin: 0; font-size: 15px; color: var(--ink); }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--ink-soft); }
details ol { padding-left: 20px; margin: 8px 0 0; }

/* top bar */
.top { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin-bottom: 12px; }
.top .where { flex: 1; min-width: 240px; }
.top .where .big { font-family: Georgia, serif; font-size: 20px; }
.news { flex: 1.3; min-width: 240px; background: var(--gold-soft); border-color: var(--gold); }
.news b { font-family: Georgia, serif; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.col { display: grid; gap: 12px; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 32px; }
}

/* action panel */
.action { border: 2px solid var(--red); }
.action.waiting { border: 1px solid var(--line); }
.action .status { font-size: 16px; }
.action .btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.action .group { margin-top: 12px; }
.action .group > .soft { margin-bottom: 4px; }
.hint { background: var(--teal-soft); color: #0e4f4a; border-radius: 8px; padding: 6px 10px; margin-top: 8px; font-size: 13px; }
.warn { background: var(--red-soft); color: #7a2018; border-radius: 8px; padding: 6px 10px; margin-top: 8px; font-size: 13px; }

/* board */
.lane { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--line); }
.lane:first-of-type { border-top: 0; }
.lane .name { font-family: Georgia, serif; font-size: 14px; }
.lane .name .flag { display: block; font-family: inherit; font-size: 11px; color: var(--gold); font-weight: 700; }
.lane .name .flag.shut { color: var(--red); }
.plots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.plot { height: 34px; border-radius: 6px; border: 1px dashed var(--line-strong); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; }
.plot.full { border: 0; }
.lane .under { grid-column: 2; font-size: 12px; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-height: 20px; }
.lane.boom { background: #fdf3d9; }
.lane.shut { background: #f7e6e2; }

/* players */
.player { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); align-items: start; }
.player:first-of-type { border-top: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; display: inline-block; }
.player .who { font-weight: 700; }
.player .izzat { font-family: Georgia, serif; font-size: 20px; text-align: right; line-height: 1.1; }
.player .izzat small { display: block; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.tagline { font-size: 12px; color: var(--ink-soft); }
.badge { display: inline-block; font-size: 11px; border-radius: 6px; padding: 1px 6px; margin-right: 4px; background: var(--teal-soft); color: #0e4f4a; }
.badge.bad { background: var(--red-soft); color: #7a2018; }
.badge.turn { background: var(--gold-soft); color: #6b4706; }

.pouch .coins { font-family: Georgia, serif; font-size: 28px; line-height: 1; }
.pouch .facts { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
.stock { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }

.log { max-height: 320px; overflow: auto; font-size: 13px; }
.log div { padding: 3px 0; border-top: 1px dashed var(--line); }
.log div:first-child { border-top: 0; font-weight: 600; }
.log .mark { color: var(--ink-faint); font-family: Georgia, serif; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: right; padding: 6px 8px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { border-top: 0; color: var(--ink-soft); font-weight: 600; font-size: 12px; }
tr.win td { background: var(--gold-soft); font-weight: 700; }
td.total { font-family: Georgia, serif; font-size: 18px; }
.end .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.scroll { overflow-x: auto; }

@media (max-width: 520px) {
  #app { padding: 10px; }
  .action .group .btns { display: grid; grid-template-columns: 1fr 1fr; }
  .action .group .btns button { text-align: left; }
  .lane { grid-template-columns: 58px minmax(0, 1fr); }
}

/* where we are in the round, and what just happened */
.phases { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.phases span { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-faint); background: #fff; }
.phases span.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.recap { border-left: 3px solid var(--gold); padding: 2px 0 2px 10px; margin-bottom: 10px; }
.recap div { padding: 2px 0; }
.recap div:last-child { font-weight: 600; }
ul.plain { margin: 0; padding-left: 18px; font-size: 14px; }
ul.plain li { padding: 1px 0; }
