/* CardScaper table styles. Shared by every game: felt, cards, seats, overlays. */
:root {
  --felt-1: #2f7a6c;
  --felt-2: #1d5148;
  --felt-3: #0e2e2a;
  --gold: #e8c35a;
  --gold-deep: #b98a2d;
  --cream: #faf6ec;
  --panel: rgba(6, 24, 22, .86);
  --red: #d2342a;
  --ink: #1c2430;
  --blue: #1f6fbf;
  --green: #0f7a44;
  --cw: min(21.5vw, 15vh, 112px);       /* hand card width */
  --mw: min(8.4vw, 6.4vh, 44px);      /* opponent card width */
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--sans); color: var(--cream); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 38%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------- buttons -------------------------------- */
.btn {
  background: linear-gradient(180deg, #f3d87c, #cda23a); color: #3a2a06;
  border: 1px solid #fff3c4; border-radius: 999px; font-weight: 800; font-size: 16px;
  letter-spacing: .03em; padding: 12px 30px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.6);
  transition: transform .12s;
}
.btn:hover { transform: scale(1.03); }
.btn:disabled { opacity: .4; transform: none; cursor: default; }
.btn.ghost {
  background: rgba(232,195,90,.08); color: var(--cream); border: 1.5px solid rgba(232,195,90,.55);
  box-shadow: none; font-weight: 700;
}
.btn.small { font-size: 13.5px; padding: 8px 18px; }
.icon-btn {
  background: rgba(0,0,0,.28); border: 1px solid rgba(232,195,90,.35); border-radius: 999px;
  min-width: 40px; height: 40px; padding: 0 12px; font-size: 14px; font-weight: 700;
}

/* -------------------------------- cards --------------------------------- */
.card {
  --w: var(--cw);
  width: var(--w); height: calc(var(--w) * 1.4); flex: none; position: relative;
  background: linear-gradient(180deg, #fff, #f3efe4); border-radius: calc(var(--w) * .09);
  border: 1px solid rgba(0,0,0,.25); box-shadow: 0 2px 6px rgba(0,0,0,.35);
  color: var(--ink); font-family: var(--serif); font-weight: 700; line-height: 1;
}
.card.s-H { color: var(--red); }
.card.s-D { color: var(--blue); }
.card.s-C { color: var(--green); }
.card .corner { position: absolute; top: 6%; left: 8%; text-align: center; font-size: calc(var(--w) * .27); }
.card .corner i { display: block; font-style: normal; font-size: calc(var(--w) * .25); margin-top: 2%; }
.card .pip { position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%); font-size: calc(var(--w) * .58); }
.card.mini .corner { top: 9%; left: 0; right: 0; font-size: calc(var(--w) * .42); }
.card.mini .corner i { font-size: calc(var(--w) * .44); }
.card.mini .pip { display: none; }
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 4px, transparent 4px 8px),
    linear-gradient(160deg, #8a2a22, #5c1712);
  border: calc(var(--w) * .05) solid #f6efdc;
}
.card.back::after {
  content: '♠'; position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(232,195,90,.85); font-size: calc(var(--w) * .42);
}
button.card { cursor: pointer; padding: 0; }
button.card:disabled { cursor: default; }

/* -------------------------------- screens ------------------------------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* Menu */
#menu { align-items: center; overflow-y: auto; padding: 22px 16px 30px; }
.menu-box { width: 100%; max-width: 440px; margin: auto; }
.wordmark { font-family: var(--serif); font-size: 15px; color: var(--gold); text-decoration: none; font-weight: 700; }
.menu-title { font-family: var(--serif); font-size: clamp(56px, 17vw, 84px); line-height: .95; color: #fdf4d7; text-shadow: 0 3px 18px rgba(0,0,0,.4); margin: 6px 0 2px; }
.menu-sub { opacity: .85; margin-bottom: 18px; font-size: 15px; }
.profile {
  background: var(--panel); border: 1px solid rgba(232,195,90,.3); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px;
}
.profile-top { display: flex; align-items: center; gap: 12px; }
.lvl-badge {
  flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #f7e09a, #b98a2d); color: #3a2a06;
  font-family: var(--serif); font-weight: 800; font-size: 23px; border: 2px solid #fff3c4;
}
.profile-name { flex: 1; min-width: 0; }
.profile-name input {
  width: 100%; background: transparent; border: none; border-bottom: 1px dashed rgba(232,195,90,.45);
  color: var(--cream); font: 700 17px var(--sans); padding: 2px 0; user-select: text; -webkit-user-select: text;
}
.profile-name small { display: block; opacity: .75; font-size: 12.5px; margin-top: 3px; }
.bar { height: 8px; border-radius: 99px; background: rgba(0,0,0,.4); overflow: hidden; margin-top: 12px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #cda23a, #f7e09a); border-radius: 99px; transition: width .6s; }
.profile-stats { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 12.5px; opacity: .9; }
.profile-stats b { color: #fdf0c9; }
.field-label { font-size: 13px; font-weight: 700; opacity: .85; margin: 14px 0 7px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  flex: 1; min-width: 46px; background: rgba(0,0,0,.28); border: 1.5px solid rgba(232,195,90,.3);
  border-radius: 12px; padding: 9px 6px; font-weight: 700; font-size: 15px;
}
.chip-btn small { display: block; font-weight: 600; font-size: 11px; opacity: .7; margin-top: 1px; }
.chip-btn[aria-pressed="true"] { background: rgba(232,195,90,.2); border-color: var(--gold); color: #fdf0c9; }
.menu-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.menu-actions > .btn { width: 100%; font-size: 18px; padding: 14px; }
.menu-links { display: flex; gap: 8px; margin-top: 4px; }
.menu-links > * { flex: 1; text-align: center; text-decoration: none; white-space: nowrap; padding: 9px 6px !important; }
.save-note { font-size: 12px; opacity: .65; text-align: center; margin-top: 16px; line-height: 1.5; }

/* Table */
#table { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px; }
.topbar .spacer { flex: 1; }
.lvl-chip {
  display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.28);
  border: 1px solid rgba(232,195,90,.35); border-radius: 999px; padding: 5px 12px 5px 6px; font-size: 12.5px; font-weight: 700;
}
.lvl-chip .n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #f7e09a, #b98a2d); color: #3a2a06; font-family: var(--serif); font-size: 14px;
}
.lvl-chip .bar { width: 64px; margin: 0; height: 6px; }

.seats { display: flex; justify-content: space-evenly; align-items: flex-start; gap: 4px; padding: 6px 6px 0; min-height: calc(var(--mw) * 1.4 + 64px); }
.seat { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; min-width: 0; transition: opacity .4s; }
.seat.out { opacity: .32; }
.seat-id { display: flex; align-items: center; gap: 6px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(0,0,0,.35); border: 2px solid rgba(232,195,90,.4); font-weight: 800; font-size: 13px;
  transition: box-shadow .25s, border-color .25s;
}
.seat.turn .avatar, .me.turn .avatar { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,195,90,.35), 0 0 16px rgba(255,220,120,.7); }
.seat-name { font-size: 12.5px; font-weight: 700; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lives { display: flex; gap: 3px; }
.lives i { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f7e09a, #b98a2d); border: 1px solid #fff3c4; transition: all .4s; }
.lives i.gone { background: rgba(0,0,0,.4); border-color: rgba(255,255,255,.18); transform: scale(.8); }
.seat-cards { display: flex; min-height: calc(var(--mw) * 1.4); }
.seat-cards .card { --w: var(--mw); margin-left: calc(var(--mw) * -.38); }
.seat-cards .card:first-child { margin-left: 0; }
.seat.reveal .seat-cards .card { margin-left: 2px; }
.tag {
  font-size: 10.5px; font-weight: 800; border-radius: 99px; padding: 2px 8px; white-space: nowrap;
  background: rgba(0,0,0,.45); border: 1px solid rgba(232,195,90,.45); color: #fdf0c9;
}
.tag.value { background: #fdf4d7; color: #3a2a06; border-color: #fff; font-size: 12px; }
.tag.low { background: var(--red); color: #fff; border-color: #ffb3ad; }
.tag.high { background: #2e8b57; color: #fff; border-color: #a9e8c4; }
.seat-tags { display: flex; gap: 4px; min-height: 18px; flex-wrap: wrap; justify-content: center; }
.shake { animation: shake .5s; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

.emote {
  position: fixed; transform: translateX(-50%); z-index: 75; pointer-events: none;
  background: #fff; border-radius: 16px 16px 16px 4px; padding: 3px 8px; font-size: 22px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4); animation: pop 2.2s forwards;
}
@keyframes pop { 0% { transform: translateX(-50%) scale(0); } 10% { transform: translateX(-50%) scale(1.15); } 16%, 85% { transform: translateX(-50%) scale(1); opacity: 1; } 100% { transform: translateX(-50%) scale(.8); opacity: 0; } }

.center { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 0; padding: 4px 10px; }
.piles { display: flex; gap: clamp(16px, 6vw, 38px); align-items: flex-end; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; }
.pile .card, .pile .slot { --w: min(19vw, 12vh, 92px); }
.pile .slot { width: var(--w); height: calc(var(--w) * 1.4); border-radius: calc(var(--w) * .09); border: 2px dashed rgba(255,255,255,.25); }
.pile small { font-size: 12px; font-weight: 700; opacity: .8; }
.pile.live .card { box-shadow: 0 0 0 3px var(--gold), 0 0 18px 4px rgba(255,220,120,.6); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 26px 8px rgba(255,220,120,.75); } }
#stock .card { box-shadow: 0 2px 0 #3b0f0b, 0 4px 0 #f6efdc, 0 6px 0 #3b0f0b, 0 8px 10px rgba(0,0,0,.4); }
.status {
  text-align: center; font-size: clamp(14px, 3.6vw, 17px); font-weight: 700; min-height: 2.6em; max-width: 520px;
  display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.status.big { font-family: var(--serif); font-size: clamp(20px, 5.4vw, 28px); color: #fdf4d7; }

.me { padding: 0 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; }
.me-row { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.hand { display: flex; justify-content: center; gap: clamp(4px, 1.4vw, 10px); min-height: calc(var(--cw) * 1.4 + 16px); align-items: flex-end; }
.hand .card { transition: transform .16s, box-shadow .16s, opacity .2s; }
.hand .card.sel { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--gold), 0 10px 18px rgba(0,0,0,.45); }
.hand .card.fresh { box-shadow: 0 0 0 3px rgba(120,200,255,.9), 0 4px 10px rgba(0,0,0,.4); }
.hand .card.locked { opacity: .55; }
.hand .card.dim { opacity: .5; }
.actions { display: flex; gap: 10px; align-items: center; justify-content: center; min-height: 46px; flex-wrap: wrap; }
.emote-tray { position: absolute; bottom: 62px; right: 10px; background: var(--panel); border: 1px solid rgba(232,195,90,.4); border-radius: 14px; padding: 6px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; z-index: 20; }
.emote-tray button { background: none; border: none; font-size: 26px; padding: 6px 8px; border-radius: 10px; }
.emote-tray button:hover { background: rgba(232,195,90,.18); }

/* Flying cards and XP drops */
#fly { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
#fly .card { position: absolute; left: 0; top: 0; will-change: transform; }
#drops { position: absolute; top: 2px; left: 0; right: 0; z-index: 70; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; pointer-events: none; }
.drop {
  background: rgba(0,0,0,.6); border: 1px solid rgba(232,195,90,.55); border-radius: 99px; padding: 4px 12px;
  font-size: 13px; font-weight: 800; color: #fdf0c9; animation: drop 2.4s forwards;
}
.drop span { font-weight: 600; opacity: .8; margin-left: 6px; }
@keyframes drop { 0% { transform: translateY(14px); opacity: 0; } 12%, 78% { transform: none; opacity: 1; } 100% { transform: translateY(-16px); opacity: 0; } }
.toast {
  position: fixed; left: 50%; top: 24%; transform: translateX(-50%); z-index: 80; text-align: center; pointer-events: none;
  background: linear-gradient(180deg, #f7e09a, #cda23a); color: #3a2a06; border: 2px solid #fff3c4; border-radius: 18px;
  padding: 14px 26px; box-shadow: 0 14px 40px rgba(0,0,0,.5); animation: toast 3s forwards; min-width: 230px;
}
.toast b { display: block; font-family: var(--serif); font-size: 24px; }
.toast small { font-size: 13.5px; font-weight: 700; }
@keyframes toast { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 10% { transform: translateX(-50%) scale(1.05); opacity: 1; } 16%, 84% { transform: translateX(-50%) scale(1); opacity: 1; } 100% { transform: translateX(-50%) scale(.95); opacity: 0; } }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(2, 12, 11, .72); z-index: 90; display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.sheet {
  width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; background: linear-gradient(180deg, #143b35, #0b2622);
  border: 1px solid rgba(232,195,90,.45); border-radius: 20px; padding: 22px 20px; box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.sheet h2 { font-family: var(--serif); font-size: 28px; color: #fdf4d7; margin-bottom: 4px; }
.sheet p { opacity: .88; font-size: 14.5px; margin-bottom: 12px; line-height: 1.5; }
.rows { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 14px; }
.rows td { padding: 7px 4px; border-bottom: 1px solid rgba(232,195,90,.16); }
.rows td:last-child { text-align: right; font-weight: 700; color: #fdf0c9; white-space: nowrap; }
.rows tr.total td { border-bottom: none; font-size: 16px; font-weight: 800; color: var(--gold); padding-top: 10px; }
.rows .muted { opacity: .6; font-weight: 400; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet-actions .btn { flex: 1; padding: 12px 10px; }
.tier { font-size: 12px; font-weight: 800; color: var(--gold); margin: 14px 0 4px; }
.ach { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid rgba(232,195,90,.14); font-size: 14px; }
.ach .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(232,195,90,.4); flex: none; display: grid; place-items: center; font-size: 13px; color: #3a2a06; }
.ach.done .tick { background: var(--gold); border-color: #fff3c4; }
.ach .what { flex: 1; }
.ach .what small { display: block; opacity: .65; font-size: 12px; }
.ach .xp { font-size: 12.5px; font-weight: 700; color: #fdf0c9; white-space: nowrap; }

@media (min-width: 760px) {
  :root { --cw: min(13vh, 118px); --mw: min(6.4vh, 50px); }
  .seat-name { max-width: 110px; font-size: 14px; }
  .avatar { width: 36px; height: 36px; font-size: 15px; }
}
@media (max-height: 520px) {
  :root { --cw: min(17vh, 78px); --mw: min(8vh, 32px); }
  .topbar { padding: 5px 10px 0; }
  .icon-btn { height: 34px; min-width: 34px; }
  .lvl-chip { padding: 3px 10px 3px 4px; }
  .seats { min-height: 0; padding-top: 2px; }
  .seat { gap: 2px; }
  .seat-tags { min-height: 0; }
  .avatar { width: 26px; height: 26px; font-size: 12px; }
  .center { flex-direction: row; gap: 22px; padding: 0 10px; }
  .pile { gap: 2px; }
  .pile .card, .pile .slot { --w: min(15vh, 62px); }
  .status { max-width: 260px; min-height: 0; }
  .me { flex-direction: row; justify-content: center; align-items: flex-end; gap: 16px; padding-bottom: 6px; }
  .me-row { flex-direction: column; gap: 5px; min-width: 110px; }
  .hand { min-height: calc(var(--cw) * 1.4 + 14px); }
  .actions { flex-direction: column; gap: 6px; min-width: 110px; }
  .btn { padding: 9px 20px; font-size: 14.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .emote, .drop, .toast { animation-duration: 2.4s !important; }
}
