:root {
  --felt: #14532d;
  --felt2: #166534;
  --ink: #0f172a;
  --paper: #fffdf5;
  --gold: #f5b301;
  --red: #dc2626;
  --green: #16a34a;
  --blue: #2563eb;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, var(--felt2), var(--felt) 70%);
  color: #f0fdf4;
  overscroll-behavior: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: .6rem 1rem; font-weight: 700; background: var(--gold); color: #422006; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: rgba(255,255,255,.12); color: #f0fdf4; }
button.danger { background: var(--red); color: #fff; }
input, select { font: inherit; padding: .6rem .8rem; border-radius: 10px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); color: #fff; width: 100%; }
input::placeholder { color: rgba(255,255,255,.5); }
h1 { margin: 0; font-size: 2.2rem; letter-spacing: .02em; }
.center { margin: auto; width: min(94vw, 420px); padding: 1.5rem 0; display: grid; gap: .9rem; }
.panel { background: rgba(0,0,0,.28); border-radius: var(--radius); padding: 1rem; display: grid; gap: .7rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.muted { opacity: .7; font-size: .9rem; }
.code { font-size: 2.6rem; font-weight: 900; letter-spacing: .3em; text-align: center; background: rgba(0,0,0,.3); border-radius: var(--radius); padding: .2rem .2rem .2rem .5rem; }
.seat { display: flex; justify-content: space-between; align-items: center; padding: .5rem .7rem; background: rgba(255,255,255,.08); border-radius: 10px; }
.seat small { opacity: .7; }
.seat button { padding: .25rem .6rem; flex: none; }
.tag { font-size: .7rem; padding: .1rem .4rem; border-radius: 6px; background: var(--gold); color: #422006; margin-left: .4rem; }

/* game */
.game { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; height: 100dvh; max-width: 1100px; margin: 0 auto; width: 100%; }
.topbar { display: flex; gap: .6rem; align-items: center; padding: .5rem .7rem; font-size: .85rem; background: rgba(0,0,0,.3); }
.topbar .grow { flex: 1; }
.turnbadge { padding: .25rem .6rem; border-radius: 999px; background: rgba(255,255,255,.12); font-weight: 700; }
.turnbadge.me { background: var(--gold); color: #422006; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.board { overflow-y: auto; padding: .6rem; display: grid; gap: .6rem; align-content: start; }
.lane { background: rgba(0,0,0,.25); border-radius: var(--radius); padding: .6rem .7rem; display: grid; gap: .4rem; border: 2px solid transparent; }
.lane.mine { border-color: rgba(245,179,1,.6); }
.lane.active { box-shadow: 0 0 0 3px rgba(255,255,255,.6) inset; }
.lane.target { border-color: var(--red); cursor: pointer; animation: pulse 1s infinite; }
.lane-head { display: flex; justify-content: space-between; gap: .5rem; font-weight: 700; }
.lane-head .pts { opacity: .8; font-weight: 500; font-size: .85rem; }
.track { position: relative; height: 22px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.track .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #22c55e, #86efac); border-radius: 999px; transition: width .6s; }
.track .km { position: absolute; inset: 0; display: grid; place-items: center; font-size: .75rem; font-weight: 800; text-shadow: 0 1px 2px #000; }
.lane-info { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.pill { font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: rgba(255,255,255,.12); white-space: nowrap; }
.pill.bad { background: var(--red); color: #fff; }
.pill.good { background: var(--green); color: #fff; }
.pill.gold { background: var(--gold); color: #422006; }
.status { font-weight: 800; }
.piles { display: flex; gap: .8rem; justify-content: center; align-items: center; }
.log { font-size: .8rem; opacity: .85; max-height: 5.5em; overflow-y: auto; display: flex; flex-direction: column-reverse; }
.log div { padding: .05rem 0; }

.handwrap { background: rgba(0,0,0,.35); padding: .5rem .5rem calc(.6rem + env(safe-area-inset-bottom)); display: grid; gap: .5rem; }
.hand { display: flex; gap: .4rem; justify-content: center; overflow-x: auto; padding: .4rem .2rem .2rem; }
.actions { display: flex; gap: .5rem; justify-content: center; min-height: 2.6rem; align-items: center; flex-wrap: wrap; }
.hint { font-size: .85rem; text-align: center; opacity: .9; }

.card { flex: 0 0 auto; width: 74px; height: 106px; border-radius: 10px; background: var(--paper); color: var(--ink); display: grid; grid-template-rows: 1fr auto; place-items: center; padding: .35rem .2rem; border: 3px solid #cbd5e1; box-shadow: 0 3px 6px rgba(0,0,0,.35); text-align: center; position: relative; transition: transform .15s; user-select: none; }
.card .ic { font-size: 2rem; line-height: 1; }
.card .nm { font-size: .68rem; font-weight: 800; line-height: 1.05; }
.card.dist { border-color: #3b82f6; }
.card.dist .ic { font-size: 1.7rem; font-weight: 900; color: #1d4ed8; }
.card.hazard { border-color: var(--red); background: #fff1f2; }
.card.remedy { border-color: var(--green); background: #f0fdf4; }
.card.safety { border-color: var(--gold); background: #fffbeb; }
.card.dim { opacity: .45; }
.card.sel { transform: translateY(-14px); box-shadow: 0 8px 14px rgba(0,0,0,.5); outline: 3px solid var(--gold); }
.card.mini { width: 40px; height: 56px; padding: .15rem; border-width: 2px; border-radius: 6px; }
.card.mini .ic { font-size: 1.1rem; }
.card.mini .nm { display: none; }
.card.mini.dist .ic { font-size: .95rem; }
.card.back { background: repeating-linear-gradient(45deg, #7f1d1d, #7f1d1d 6px, #991b1b 6px, #991b1b 12px); border-color: #fff; }
.card.empty { background: transparent; border: 2px dashed rgba(255,255,255,.3); box-shadow: none; color: rgba(255,255,255,.5); }
.pilelabel { font-size: .7rem; text-align: center; opacity: .8; margin-top: .2rem; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 10; padding: 1rem; }
.modal { background: #1f2937; border-radius: 16px; padding: 1.2rem; width: min(96vw, 560px); max-height: 92vh; overflow: auto; display: grid; gap: .8rem; }
.modal h2 { margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .3rem .35rem; text-align: right; border-bottom: 1px solid rgba(255,255,255,.1); }
th:first-child, td:first-child { text-align: left; }
.coup { position: fixed; left: 0; right: 0; top: 3.2rem; display: grid; place-items: center; z-index: 9; padding: .5rem; }
.coup .box { background: var(--red); color: #fff; border-radius: 14px; padding: .8rem 1rem; display: grid; gap: .5rem; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); width: min(94vw, 420px); }
.coup button { background: var(--gold); }
#toast { position: fixed; bottom: 9rem; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
@media (min-width: 700px) { .card { width: 88px; height: 126px; } .card .ic { font-size: 2.4rem; } .card .nm { font-size: .78rem; } }
