/* HERNA — shared look: an evening games club. Green baize table, cream cards, brass trim.
   Game pages add their own styles on top; keep tokens here so every game feels part of one room. */
:root {
  --felt: #1d4636;
  --felt-dark: #13322a;
  --felt-light: #2a5c47;
  --card: #f6efdd;
  --card-2: #fbf7ec;
  --card-edge: #d8ccb0;
  --ink: #221f1a;
  --ink-dim: #5f5a4f;
  --ink-faint: #8f887a;
  --brass: #c9a24b;
  --brass-dark: #8a6a24;
  --wine: #8f2d3a;
  --wine-dark: #5d1a24;
  --ok: #3c6e3f;
  --on-felt: #efe6cf;
  --on-felt-dim: #b9c7b9;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: #13322a; }
body {
  font-family: var(--sans);
  color: var(--on-felt);
  background-color: var(--felt);
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(255, 240, 200, .16), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, .35), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* Top rail */
.rail {
  background: linear-gradient(#3a2a1a, #2a1e12); color: var(--on-felt);
  border-bottom: 3px solid var(--brass-dark); box-shadow: 0 2px 0 rgba(201, 162, 75, .35), 0 6px 18px rgba(0,0,0,.35);
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; min-height: 48px; font-size: 14px;
}
.rail .brand { font-family: var(--serif); font-weight: 800; font-size: 22px; letter-spacing: .04em; text-decoration: none; color: var(--brass); display: flex; align-items: center; gap: 8px; }
.rail .brand img { width: 26px; height: 26px; }
.rail .game-name { font-family: var(--serif); font-size: 17px; color: var(--on-felt); }
.rail .sp { flex: 1; }
@media (max-width: 440px) { .rail .uname, .rail .game-name { display: none; } .rail { gap: 6px 12px; } }
.rail a.lnk, .rail button.lnk { color: var(--on-felt); background: none; border: 0; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(201,162,75,.6); text-underline-offset: 4px; padding: 6px 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 18px 16px 48px; }
.hero { text-align: center; padding: 22px 0 18px; }
.hero h1 { font-family: var(--serif); font-weight: 800; font-size: clamp(40px, 10vw, 72px); color: var(--brass); letter-spacing: .03em; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.hero p { color: var(--on-felt-dim); margin-top: 8px; font-size: 15px; }
.section-title { font-family: var(--serif); font-size: 22px; color: var(--on-felt); margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.section-title small { font-family: var(--sans); font-size: 13px; color: var(--on-felt-dim); font-weight: 400; }

/* Cards (panels) */
.panel { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 10px 24px rgba(0,0,0,.28), 0 2px 4px rgba(0,0,0,.2); }
.panel h2 { font-family: var(--serif); font-size: 24px; line-height: 1.2; margin-bottom: 6px; }
.panel h3 { font-family: var(--serif); font-size: 19px; line-height: 1.25; margin-bottom: 8px; }
.label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.muted { color: var(--ink-dim); }
.small { font-size: 13px; }
.narrow { max-width: 440px; margin: 0 auto; }
.empty { padding: 22px 0 6px; text-align: center; color: var(--ink-dim); }
.on-felt .empty, .empty.felt { color: var(--on-felt-dim); }
@media (max-width: 520px) { .panel { padding: 14px; } .panel h2 { font-size: 21px; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; background: var(--card-2); color: var(--ink);
  padding: 10px 18px; cursor: pointer; font-weight: 700; letter-spacing: .01em; text-decoration: none;
  min-height: 44px; touch-action: manipulation; box-shadow: inset 0 0 0 2px var(--ink);
  transition: transform .08s, box-shadow .12s, background .12s;
}
.btn:hover:not(:disabled) { background: #fff; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-main { background: var(--wine); color: #fff6ea; box-shadow: 0 3px 0 var(--wine-dark), 0 6px 14px rgba(0,0,0,.2); }
.btn-main:hover:not(:disabled) { background: #a3384a; }
.btn-main:active:not(:disabled) { box-shadow: 0 1px 0 var(--wine-dark); transform: translateY(2px); }
.btn-brass { background: linear-gradient(#e2c174, var(--brass)); color: #2a1e12; box-shadow: 0 3px 0 var(--brass-dark), 0 6px 14px rgba(0,0,0,.2); }
.btn-brass:hover:not(:disabled) { background: linear-gradient(#ecd08c, #d4ad57); }
.btn-quiet { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-faint); color: var(--ink-dim); }
.btn-quiet:hover:not(:disabled) { background: rgba(0,0,0,.04); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Forms — 16px inputs so iOS does not zoom in */
.field { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--ink-dim); }
.field select, .field input, .field textarea, .inp {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; background: #fff; font-size: 16px; color: var(--ink); font-weight: 400;
  border: 1.5px solid var(--card-edge); border-radius: 8px; -webkit-appearance: none; appearance: none;
}
.field select:focus, .field input:focus, .field textarea:focus, .inp:focus { outline: none; border-color: var(--brass-dark); box-shadow: 0 0 0 3px rgba(201,162,75,.3); }
select.inp, .field select { background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.err { color: var(--wine); font-weight: 700; font-size: 14px; min-height: 1.4em; margin-top: 6px; }
.tabs { display: flex; margin-bottom: 16px; background: rgba(0,0,0,.06); border-radius: 999px; padding: 4px; }
.tabs button { flex: 1; background: none; border: 0; padding: 8px; cursor: pointer; font-weight: 700; color: var(--ink-dim); min-height: 40px; border-radius: 999px; }
.tabs button.on { color: var(--ink); background: var(--card-2); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; margin-top: 12px; }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--wine); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; gap: 10px; } }

/* Lobby */
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.table-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; position: relative; overflow: hidden; }
.table-card .art { aspect-ratio: 400 / 220; margin: -18px -18px 4px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.table-card .art img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 520px) { .table-card .art { margin: -14px -14px 4px; } }
.table-card p { font-size: 14px; color: var(--ink-dim); flex: 1; }
.table-card .meta { font-size: 12px; color: var(--ink-faint); letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.games { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.game-row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 14px; align-items: center; padding: 12px 14px;
  background: var(--card); color: var(--ink); border-radius: var(--radius); cursor: pointer; text-decoration: none;
  box-shadow: 0 6px 14px rgba(0,0,0,.22); border-left: 6px solid transparent;
}
.game-row.mine { border-left-color: var(--wine); }
.game-row:hover { background: var(--card-2); }
.game-row .ico { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.game-row .t { font-weight: 700; }
.game-row .t small { font-weight: 400; color: var(--ink-faint); }
.game-row .meta { font-size: 13px; color: var(--ink-dim); }
.game-row .unread { color: var(--wine); font-weight: 700; }
.game-row .unread::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--wine); margin-right: 5px; vertical-align: 1px; }
.chip { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; font-weight: 800; white-space: nowrap; }
.chip.mine { background: var(--wine); color: #fff6ea; }
.chip.wait { background: rgba(0,0,0,.07); color: var(--ink-dim); }
.chip.win { background: var(--ok); color: #fff; } .chip.loss { background: #8f887a; color: #fff; } .chip.draw { background: var(--brass); color: #2a1e12; }
@media (max-width: 520px) { .game-row { grid-template-columns: 34px 1fr; padding: 10px 12px; } .game-row .chip { grid-column: 2; justify-self: start; } .game-row .ico { width: 34px; height: 34px; } }
details.older summary { cursor: pointer; color: var(--on-felt-dim); margin: 18px 0 10px; font-size: 14px; }

/* Game page frame */
.crumbs { font-size: 14px; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--on-felt-dim); }
.crumbs a { color: var(--on-felt); padding: 4px 0; }
.status { border-radius: 8px; padding: 10px 14px; background: rgba(0,0,0,.05); margin-bottom: 14px; font-size: 15px; border-left: 6px solid var(--ink-faint); }
.status.go { border-left-color: var(--wine); background: #f7e6e0; }
.late { color: var(--wine); font-weight: 700; }
.over-box { text-align: center; padding: 16px; border-radius: var(--radius); background: var(--card-2); margin-bottom: 14px; box-shadow: inset 0 0 0 2px var(--brass); }
.over-box h2 { font-family: var(--serif); font-size: 28px; }
.over-box .row { justify-content: center; margin-top: 12px; }

/* Timeline: game record + chat */
.timeline { max-height: 60vh; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.ev { font-size: 13px; color: var(--ink-dim); padding-left: 10px; border-left: 3px solid var(--card-edge); }
.ev b { color: var(--ink); }
.msg { max-width: 86%; align-self: flex-start; }
.msg .who { font-size: 11px; font-weight: 700; letter-spacing: .03em; margin-bottom: 1px; color: var(--ink-dim); }
.msg .who time { font-weight: 400; color: var(--ink-faint); margin-left: 4px; }
.msg .bubble { background: #fff; border: 1px solid var(--card-edge); padding: 6px 10px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 4px 12px 12px 12px; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg.mine .bubble { background: #efe3c4; text-align: left; border-radius: 12px 4px 12px 12px; }
.chatbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.chatbar textarea { resize: none; height: 44px; max-height: 120px; margin: 0; line-height: 1.3; }

.debugbar { background: #1b1f26; color: #f1ead8; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-radius: 8px; }
.debugbar > b { letter-spacing: .15em; color: var(--brass); }
.seat { background: transparent; color: #f1ead8; border: 1px solid rgba(241,234,216,.45); padding: 6px 10px; min-height: 40px; cursor: pointer; text-align: left; line-height: 1.2; border-radius: 6px; }
.seat small { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.seat.on { background: #f1ead8; color: var(--ink); }
.seat.move::after { content: " ●"; color: var(--brass); }
.debugbar label { display: flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; }
.debugbar input { width: 18px; height: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #2a1e12; color: var(--on-felt); border: 1px solid var(--brass-dark); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.foot { text-align: center; font-size: 12px; color: var(--on-felt-dim); margin-top: 34px; opacity: .8; }
