@import url("../modes.css");
/* The card table shared by the card games (games/cards/ui.js): setup, felt table, seats, piles,
   hand fan, cut and deal, score sheet, online lobby, dialogs. A game adds its own rules in its page. */
.wrap { max-width: 980px; margin: 0 auto; padding: 6px 12px 60px; }
h1 { font-family: 'Iowan Old Style','Palatino Linotype',Georgia,serif; font-size: 30px; margin: 8px 0 2px; text-align: center; }
.sub { text-align: center; color: var(--accent); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 14px; }
.panel { background: var(--card-bg); border-radius: 12px; padding: 14px 16px; box-shadow: 0 10px 26px rgba(0,0,0,.45), inset 0 0 0 1px var(--card-border); margin-bottom: 12px; }
.hidden { display: none !important; }
button, select { font: inherit; }
.btn { background: linear-gradient(160deg, #3a2a18, #251a0e); color: var(--text); border: 1px solid var(--card-border); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: linear-gradient(160deg, #c9a35c, #9c7a38); color: #1b1309; font-weight: 700; border-color: #c9a35c; }

/* setup */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.setup-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-dim); }
.setup-grid select { background: #1c140c; color: var(--text); border: 1px solid var(--card-border); border-radius: 8px; padding: 8px; font-size: 15px; }
details.rules { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
details.rules summary { cursor: pointer; color: var(--accent); }
details.rules li { margin: 3px 0; }

/* scoreboard */
.chip { padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.3); box-shadow: inset 0 0 0 1px var(--card-border); font-size: 13px; }
.chip.turn { box-shadow: inset 0 0 0 2px var(--accent); color: #fff; }
.chip b { color: var(--accent); }
.roundline { text-align: center; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

.card { position: relative; width: 66px; height: 92px; border-radius: 9px; background: none; border: none; padding: 0; cursor: pointer; flex-shrink: 0; user-select: none; transition: transform .12s; filter: drop-shadow(0 3px 3px rgba(0,0,0,.55)); display: inline-block; }
.card svg.face { width: 100%; height: 100%; display: block; pointer-events: none; }
.card.sel { transform: translateY(-14px); filter: drop-shadow(0 0 0 transparent); box-shadow: 0 0 0 3px #f2c14e, 0 8px 12px rgba(0,0,0,.6); }
.card.must { outline: 3px dashed #f2c14e; outline-offset: 2px; }
.card.empty { border: 2px dashed rgba(255,255,255,.25); filter: none; color: rgba(255,255,255,.5); font-size: 11px; display: flex; align-items: center; justify-content: center; text-align: center; cursor: default; }
.card.mini { width: 40px; height: 56px; border-radius: 6px; cursor: inherit; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
.card.tiny { width: 24px; height: 34px; border-radius: 4px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); cursor: default; }
.card .rep { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); background: #7a3fb0; color: #fff; border-radius: 4px; font-size: 10px; font-weight: 700; padding: 0 3px; line-height: 14px; display: inline-flex; align-items: center; gap: 1px; }
.card .rep svg { width: 8px; height: 8px; fill: #fff; }

/* felt table */
.felt { display: grid; gap: 10px; padding: 14px; border-radius: 22px; border: 9px solid #5a3a1f; background: radial-gradient(ellipse at 50% 35%, #23764c, #14543a 62%, #0c3a27); box-shadow: inset 0 0 40px rgba(0,0,0,.55), 0 14px 30px rgba(0,0,0,.55); margin-bottom: 10px; grid-template-columns: minmax(130px, 180px) 1fr minmax(130px, 180px); grid-template-areas: "left top right" "left center right"; align-items: start; }
.felt.n2 { grid-template-columns: 1fr; grid-template-areas: "top" "center"; }
.felt.n3 { grid-template-areas: "left center right"; }
.felt-side { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.felt-center { grid-area: center; min-width: 0; }
.center { display: flex; gap: 26px; justify-content: center; align-items: flex-start; flex-wrap: wrap; margin: 4px 0 12px; }
.pile { text-align: center; font-size: 11px; color: rgba(255,255,255,.7); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.pile .card { cursor: default; }
.pile.active .card:not(.empty) { cursor: pointer; box-shadow: 0 0 0 3px #f2c14e, 0 0 18px rgba(242,193,78,.6); }
.pile .deck-stack .card { box-shadow: 2px 2px 0 #cfc8b3, 4px 4px 0 #b8b09a, 6px 6px 0 #a39b85; }
.deck-area #deckPile { position: relative; z-index: 1; }
.deck-area { position: relative; margin-bottom: 18px; }
.deck-area:has(#fuTag:not(.hidden)) { margin-bottom: 44px; }
.pile .tilt { transform: rotate(-4deg); }
.pile .tilt2 { transform: rotate(5deg); }
#status { text-align: center; font-size: 15px; min-height: 22px; color: var(--text); margin: 4px 0 8px; }
#status.warn { color: #ff9a7a; }
/* melds are laid out like on a real table: cards cascade so every corner index shows */
.meld { display: inline-flex; padding: 6px 8px 6px 4px; border-radius: 8px; transform: rotate(var(--mr, 0deg)); }
.meld .card { width: 50px; height: 70px; margin-left: -31px; transform: rotate(var(--t, 0deg)); }
.meld .card:first-child { margin-left: 0; }
.discard-stack { position: relative; width: 66px; height: 92px; }
.discard-stack .card { position: absolute; left: 0; top: 0; }
.discard-stack .ghost { pointer-events: none; }

.hand-panel { position: sticky; bottom: 0; z-index: 10; margin-bottom: 0; background: linear-gradient(160deg, #241a11, #16110b); border-radius: 14px 14px 0 0; padding-bottom: 10px; box-shadow: 0 -8px 24px rgba(0,0,0,.6), inset 0 0 0 1px var(--card-border); }

/* cutting the deck and dealing */
.cut-panel { text-align: center; padding: 6px 0 10px; }
.cut-panel h3 { margin: 4px 0 8px; font-size: 16px; color: #fff; }
.cut-rule { display: inline-block; margin: 0 0 10px; padding: 3px 12px; border-radius: 999px; background: rgba(242,193,78,.18); box-shadow: inset 0 0 0 1px rgba(242,193,78,.6); color: #f2c14e; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.cut-rule span { font-weight: 400; opacity: .85; text-transform: none; }
.cut-spread { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 4px; max-width: 560px; margin: 0 auto 12px; }
.cut-spread .card { width: 40px; height: 56px; }
.cut-spread .card.taken { visibility: hidden; }
.cut-spread.mine .card:not(.taken):hover { transform: translateY(-8px); box-shadow: 0 0 0 3px #f2c14e; }
.cut-spread:not(.mine) .card { cursor: default; }
.cut-picks { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; }
.cut-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: rgba(255,255,255,.8); min-width: 70px; }
.cut-pick .kept { color: #d6b3ff; font-size: 11px; }
.cut-pick.winner .card { box-shadow: 0 0 0 3px #f2c14e, 0 0 16px rgba(242,193,78,.6); }
.cut-pick .slot { width: 40px; height: 56px; border: 2px dashed rgba(255,255,255,.3); border-radius: 6px; }
.cut-pick.next .slot { border-color: #f2c14e; }
.flycard { position: fixed; left: 0; top: 0; width: 40px; height: 56px; z-index: 50; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,.6)); }
.flycard svg { width: 100%; height: 100%; display: block; }

/* seats */
.seat { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(8, 22, 36, .72); box-shadow: inset 0 0 0 1px rgba(201,163,92,.35), 0 4px 10px rgba(0,0,0,.4); min-width: 0; }
.seat.turn { box-shadow: inset 0 0 0 2px #f2c14e, 0 0 18px rgba(242,193,78,.55); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 2px #f2c14e, 0 0 6px rgba(242,193,78,.2); } }
.seat.gone { opacity: .75; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; flex-shrink: 0; background: radial-gradient(circle at 35% 30%, hsl(var(--hue) 55% 62%), hsl(var(--hue) 45% 32%)); box-shadow: 0 0 0 3px hsl(var(--hue) 60% 55%), 0 3px 6px rgba(0,0,0,.5); position: relative; }
.avatar .dealer { position: absolute; right: -6px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: #f2c14e; color: #2a1d0c; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.6); }
.seat-info { min-width: 0; flex: 1; }
.seat-name { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-score { font-size: 12px; color: var(--accent); }
.seat-score b { color: #fff; font-size: 14px; }
.seat-status { font-size: 11px; color: rgba(255,255,255,.65); }
.seat-status .ok { color: #8be28b; }
.fan { display: flex; align-items: center; justify-content: center; height: 44px; min-width: 56px; padding-left: 14px; }
.fan .card.tiny { margin-left: -14px; transform-origin: 50% 120%; }
.fan-count { position: absolute; top: -8px; right: -6px; background: #f2c14e; color: #2a1d0c; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px; box-shadow: 0 1px 3px rgba(0,0,0,.6); }
.seat .fan-wrap { position: relative; }
.seat:not(.me) { flex-direction: column; text-align: center; gap: 4px; }
.seat:not(.me) .seat-info { flex: none; width: 100%; }
.seat:not(.me) .avatar { width: 46px; height: 46px; font-size: 26px; }
.seat:not(.me) .fan { padding-left: 14px; height: 40px; }
.seat.me { margin-bottom: 4px; }
.seat.me .seat-info { flex: 0 1 auto; }
.seat.me .seat-name { font-size: 15px; }
.seat.me .turn-tag { margin-left: auto; font-size: 12px; font-weight: 700; color: #2a1d0c; background: #f2c14e; border-radius: 999px; padding: 3px 10px; }

#handArea { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 4px 22px; }
#drawnWrap { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0 0; }
#drawnWrap .btn { padding: 3px 10px; font-size: 12px; }
.drawn-label { font-size: 12px; color: var(--text-dim); }
#drawnSlot .card.drawn { box-shadow: 0 0 0 3px #8be28b, 0 4px 8px rgba(0,0,0,.6); }
#drawnSlot .card, #hand .card { touch-action: none; }
#hand .card.dragging { z-index: 5; opacity: .9; transition: none; box-shadow: 0 10px 18px rgba(0,0,0,.7); cursor: grabbing; }
/* the hand is held as a fan: cards sit on an arc and tilt outwards (see layoutHand) */
#hand { position: relative; flex: 1 1 320px; min-width: 0; height: 130px; }
#hand .card { position: absolute; margin: 0; transform: rotate(var(--r, 0deg)); transform-origin: 50% 50%; transition: transform .12s; }
/* fallback until layoutHand() fans the cards out: a simple overlapping row, never a stack */
#hand .card { left: calc(var(--i, 0) * 22px + 6px); top: 24px; }
#hand .card.sel { transform: rotate(var(--r, 0deg)) translateY(-18px); }
#hand .card.dragging { transition: none; }
.hand-panel .actions { margin-top: 6px; gap: 6px; }
.hand-panel .actions .btn { padding: 6px 10px; font-size: 13px; }
.hand-panel { padding-top: 8px; }
.seat.me .avatar { width: 40px; height: 40px; font-size: 24px; }
.seat.me { padding: 5px 10px; }
body.playing h1, body.playing .sub { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.sheet { width: auto; margin: 0 auto; }
.sheet th, .sheet td { text-align: center; padding: 4px 14px; border-bottom: 1px solid rgba(201,163,92,.12); }
.sheet tr.cycle td { border-bottom: 2px solid var(--accent); }
.sheet .star { margin-left: 3px; color: var(--accent); font-weight: 700; }
.sheet-note { text-align: center; font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.hero { text-align: center; padding: 8px 0 18px; }
.hero { overflow-x: clip; } /* the rotated fan may poke a few px past a 320 px screen */
.hero-fan { height: 124px; display: flex; justify-content: center; align-items: flex-end; margin-bottom: 14px; }
.hero-fan .card { margin-left: -34px; transform-origin: 50% 130%; width: 74px; height: 104px; cursor: default; }
.hero-fan .card:first-child { margin-left: 0; }
.hero-pitch { max-width: 560px; margin: 8px auto 16px; font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.hero-cta { display: inline-block; margin: 0 4px 6px; text-decoration: none; }
html { scroll-behavior: smooth; }
.landing-rules h2 { font-family: 'Iowan Old Style','Palatino Linotype',Georgia,serif; text-align: center; font-size: 26px; margin: 26px 0 14px; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.rule-card { background: var(--card-bg); border-radius: 12px; padding: 14px 16px; box-shadow: inset 0 0 0 1px var(--card-border), 0 8px 20px rgba(0,0,0,.4); }
.rule-card.wide { grid-column: 1 / -1; }
.rule-card h3 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.rule-card p, .rule-card li { font-size: 13.5px; line-height: 1.55; color: var(--text); margin: 6px 0 0; }
.rule-card ol { margin: 0; padding-left: 20px; }
.ex { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px; border-radius: 10px; background: radial-gradient(ellipse at 50% 35%, #23764c, #14543a 70%); box-shadow: inset 0 0 14px rgba(0,0,0,.5); }
.ex .meld .card { width: 46px; height: 64px; margin-left: -28px; }
.ex .meld .card:first-child { margin-left: 0; }
.score-table { font-size: 13px; margin: 0; }
.score-table th, .score-table td { padding: 5px 6px; }
body.playing .landing-rules, body.playing .hero { display: none; }
.resume-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 14px; padding: 12px 14px; border-radius: 10px; background: rgba(242,193,78,.12); box-shadow: inset 0 0 0 1px rgba(242,193,78,.55); font-size: 14px; }
.resume-info { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
/* no pull-to-refresh while playing: scrolling up must never reload the page and lose the game */
html:has(body.playing), body.playing { overscroll-behavior-y: none; }
.conn.away { width: 8px; height: 8px; border-radius: 50%; background: #f5a623; animation: awayblink 1s ease-in-out infinite; }
@keyframes awayblink { 50% { opacity: .25; } }
.btn.subtle { padding: 3px 10px; font-size: 12px; opacity: .7; }
.conn { display: inline-block; vertical-align: middle; margin-left: 6px; font-size: 11px; }
.conn.online { width: 8px; height: 8px; border-radius: 50%; background: #58d68d; box-shadow: 0 0 6px rgba(88,214,141,.8); }
.online-box { margin: 0 0 14px; padding-top: 12px; border-top: 1px solid var(--card-border); }
.online-box h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
.online-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.online-row input { background: #1c140c; color: var(--text); border: 1px solid var(--card-border); border-radius: 8px; padding: 8px 10px; font-size: 15px; min-width: 0; }
#roomCodeInput { width: 110px; text-transform: uppercase; letter-spacing: .15em; text-align: center; }
#nameInput { width: 150px; }
.room-code { font-size: 26px; letter-spacing: .25em; font-weight: 700; color: #7fc98f; background: rgba(0,0,0,.25); border-radius: 8px; padding: 8px; text-align: center; margin-bottom: 8px; }
#seatList { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
#seatList li { padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.25); box-shadow: inset 0 0 0 1px var(--card-border); font-size: 14px; }
#seatList li.empty { color: var(--text-dim); font-style: italic; }
#onlineStatus { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
#onlineStatus.error { color: #ff9a7a; }
.log { font-size: 12px; color: var(--text-dim); margin-top: 10px; line-height: 1.5; text-align: center; }

table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--card-border); }
td.num, th.num { text-align: right; }
.win { color: #8be28b; }

@media (max-width: 760px) {
  .felt { grid-template-columns: 1fr 1fr 1fr; grid-template-areas: "left top right" "center center center"; padding: 10px; border-width: 6px; gap: 8px; }
  .felt.n2 { grid-template-columns: 1fr; grid-template-areas: "top" "center"; }
  .felt.n3 { grid-template-columns: 1fr 1fr; grid-template-areas: "left right" "center center"; }
  .seat:not(.me) { padding: 6px; }
  .seat:not(.me) .avatar { width: 38px; height: 38px; font-size: 21px; }
  .seat:not(.me) .fan-wrap { display: none; }
  .hand-panel .actions .btn { padding: 5px 8px; font-size: 12px; }
  #drawnWrap { flex-direction: row; padding-top: 6px; gap: 8px; }
  #drawnWrap .drawn-label { display: none; }
}
@media (max-width: 520px) {
  .card { width: 52px; height: 73px; }
  .card.mini { width: 32px; height: 45px; }
  .meld .card { width: 40px; height: 56px; margin-left: -25px; }
  .discard-stack { width: 52px; height: 73px; }
}

/* comfortable touch targets (44px) on the landing and setup screens; the game screen keeps its compact controls */
@media (pointer: coarse), (max-width: 760px) {
  body:not(.playing) .back-link { display: inline-block; padding: 14px 12px; }
  .hero-cta, #setup .btn, #setup select, #setup input, #rules .actions .btn { min-height: 44px; box-sizing: border-box; }
  .hero-cta { display: inline-flex; align-items: center; justify-content: center; }
}

/* a refused join or an ended room: the lobby box carries only the reason */
#lobby.msg-only .room-line, #lobby.msg-only .share-note, #lobby.msg-only #seatList, #lobby.msg-only .online-row { display: none; }
