* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c2a4a; font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif; color: #2b2d42; -webkit-user-select: none; user-select: none; }
.hidden { display: none !important; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #3b5a9a 0%, #25396b 55%, #141f3d 100%); }
#hud { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
#status { flex: 1; min-width: 0; text-align: center; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); line-height: 1.15; }
#st-main { font-weight: 800; font-size: clamp(15px, 4.2vmin, 22px); }
#st-info { font-weight: 700; font-size: clamp(12px, 3.2vmin, 16px); opacity: .85; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; font-size: 24px; font-weight: 900; color: #2b2d42; cursor: pointer; flex: none; box-shadow: 0 3px 0 rgba(0,0,0,.25); display: grid; place-items: center; padding: 0; }
.round:active { transform: translateY(2px); box-shadow: none; }

#stage { position: relative; flex: 1 1 auto; min-height: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.seat-label { position: absolute; transform: translate(-50%, -50%); min-width: 74px; max-width: 84px; padding: 3px 6px 4px; border-radius: 14px; background: rgba(255,255,255,.93); border: 3px solid rgba(40,40,80,.35); text-align: center; line-height: 1.15; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: opacity .2s; }
.seat-label .sl-name { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-label .sl-stack { font-weight: 900; font-size: 14px; color: #1b6f4a; }
.seat-label .sl-stack::before { content: "●"; color: #e8454d; margin-right: 4px; font-size: 11px; }
.seat-label .sl-tag { min-height: 1.15em; font-weight: 700; font-size: 11px; color: #5a4fcf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-label.active { background: #ffd23f; border-color: #e07a00; }
.seat-label.me { border-color: #4cd07d; }
.seat-label.fold, .seat-label.out { opacity: .55; }
.seat-label.fold .sl-tag, .seat-label.out .sl-tag { color: #8a2c2c; }
.seat-label.allin .sl-tag { color: #c0392b; font-weight: 900; }
.seat-label.win { background: #fff1b8; border-color: #f2b21f; }
.seat-label.win .sl-tag { color: #1b6f4a; }
#labels.dense .seat-label { min-width: 58px; max-width: 66px; padding: 1px 4px 2px; border-width: 2px; border-radius: 10px; }
#labels.dense .sl-name { font-size: 11px; }
#labels.dense .sl-stack { font-size: 12px; }
#labels.dense .sl-tag { font-size: 9px; }
#toast { position: absolute; left: 50%; top: calc(4px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); background: rgba(20,24,40,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: clamp(.85rem, 2.6vmin, .95rem); line-height: 1.25; box-shadow: 0 2px 8px rgba(0,0,0,.18); opacity: 0; transition: opacity .18s; pointer-events: none; max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; z-index: 5; }
#toast.show { opacity: 1; }

#raisebox { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20, 24, 60, .55); z-index: 20; overflow-y: auto; padding: 6px; }
.raise-panel { background: #fff; border-radius: 26px; padding: 10px 16px; text-align: center; max-height: 100%; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.raise-panel p { margin: 0; font-weight: 900; font-size: clamp(17px, 4.5vmin, 24px); }
.raise-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0; flex-wrap: wrap; }
#raise-amt { min-width: 100px; font-weight: 900; font-size: clamp(34px, 9vmin, 52px); color: #e8454d; }
.raise-sub { font-size: 13px; opacity: .7; margin-bottom: 4px; }
.raise-presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0; }

#side { flex: none; display: flex; flex-direction: column; max-height: 46dvh; background: rgba(10, 14, 40, .5); border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); overflow-y: auto; }
#me-row { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 10px 2px; }
#hand { flex: none; display: flex; gap: 6px; }
#info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#help { color: #fff; font-weight: 800; font-size: clamp(14px, 3.8vmin, 18px); line-height: 1.15; min-height: 1.15em; }
#help small { display: block; font-weight: 700; opacity: .8; font-size: .8em; }
#result { color: #1f2a52; background: #fff1b8; border-radius: 14px; padding: 5px 9px; font-weight: 800; font-size: clamp(13px, 3.5vmin, 17px); line-height: 1.2; white-space: pre-line; }
#info-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.round.small { width: 48px; height: 48px; font-size: 22px; }
#bar { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 6px 8px 8px; }
#bar .btn { flex: 1 1 42%; min-width: 120px; }
#bar .btn.big { flex: 1 1 100%; }

.btn { min-height: 52px; padding: 8px 16px; border-radius: 28px; border: 0; background: #ffd23f; color: #2b2d42; font: 800 clamp(16px, 4.2vmin, 22px) "Trebuchet MS", Arial, sans-serif; cursor: pointer; box-shadow: 0 4px 0 #c99200; }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn:disabled { opacity: .4; }
.btn.ghost { background: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.btn.small { min-height: 48px; font-size: 16px; padding: 6px 14px; }
.btn.fold { background: #ff8f8f; box-shadow: 0 4px 0 #c24d4d; }
.btn.call { background: #4cd07d; box-shadow: 0 4px 0 #249455; color: #fff; }
.btn.raise { background: #ffd23f; }
.btn.allin { background: #ff5a5f; color: #fff; box-shadow: 0 4px 0 #b32d31; }
.btn.big { min-height: 64px; padding: 10px 34px; font-size: clamp(22px, 6vmin, 30px); background: #4cd07d; box-shadow: 0 5px 0 #249455; color: #fff; }

.card { flex: none; width: var(--card-w, clamp(54px, 15vmin, 80px)); aspect-ratio: 2 / 3; border-radius: 10px; filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); transition: opacity .2s; }
.card img { width: 100%; height: 100%; display: block; pointer-events: none; }
.card.dim { opacity: .5; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20, 28, 70, .93); z-index: 30; overflow-y: auto; padding: 8px; }
.hero { display: block; width: 100%; max-height: 20dvh; object-fit: cover; border-radius: 22px; margin: 0 0 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.hero.hidden { display: none; }
#home .panel { max-height: calc(100dvh - 16px); }
#home .row { position: sticky; bottom: -18px; background: #fff; margin: 8px -22px -18px; padding: 10px 22px 14px; z-index: 2; box-shadow: 0 -6px 10px -6px rgba(0,0,0,.2); }
#home .row .btn, #home .row .round { min-height: 64px; }
#home .row .round { min-width: 64px; }
#pass { background: #1c2a4a; z-index: 35; }
#pass .btn { min-height: 64px; }
#combos { z-index: 36; }
#combo-list { list-style: none; margin: 4px 0 0; padding: 0; text-align: left; }
#combo-list li { display: flex; align-items: center; gap: 10px; padding: 5px 6px; margin: 4px 0; border-radius: 14px; background: #f1efff; }
.mini-cards { display: flex; flex: none; }
.mini-cards img { width: clamp(28px, 8vmin, 38px); height: auto; margin-right: -8px; filter: drop-shadow(1px 1px 1px rgba(0,0,0,.35)); }
.combo-txt { min-width: 0; margin-left: 8px; line-height: 1.15; }
.combo-txt b { display: block; font-size: clamp(15px, 4vmin, 19px); }
.combo-txt small { font-size: 12px; opacity: .75; }
.row.sticky { position: sticky; bottom: -18px; background: #fff; margin: 8px -22px -18px; padding: 8px 22px 12px; box-shadow: 0 -6px 10px -6px rgba(0,0,0,.2); }
#seat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.seat { display: flex; align-items: center; gap: 8px; }
.seat input { flex: 1 1 auto; min-width: 0; height: 52px; border: 4px solid #d8d6ef; border-radius: 16px; padding: 0 12px; font: 700 18px "Trebuchet MS", Arial, sans-serif; color: #2b2d42; background: #fff; }
.seat .chips { flex: none; flex-wrap: nowrap; gap: 4px; }
.seat .chip { min-width: 64px; min-height: 52px; padding: 2px 8px; border-width: 3px; }
.seat .chip b { font-size: 16px; }
.seat .chip:disabled { opacity: .5; cursor: default; }
#end { background: rgba(20, 28, 70, .82); }
.panel { background: #fff; border-radius: 30px; padding: 18px 22px; text-align: center; width: min(520px, 100%); max-height: 100dvh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.panel h1 { margin: 0; font-size: clamp(38px, 11vmin, 64px); color: #1f9d6b; letter-spacing: 1px; text-shadow: 3px 3px 0 #f2b21f; }
.panel h2 { margin: 4px 0 8px; font-size: clamp(24px, 7vmin, 38px); }
.panel h3 { margin: 8px 0 4px; font-size: 16px; opacity: .75; }
.sub { margin: 2px 0 8px; font-weight: 700; font-size: clamp(15px, 4vmin, 20px); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { min-width: 64px; min-height: 56px; padding: 6px 12px; border-radius: 18px; border: 4px solid #d8d6ef; background: #f6f5ff; cursor: pointer; font: 700 15px "Trebuchet MS", Arial, sans-serif; color: #2b2d42; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.chip b { font-size: 22px; }
.chip small { font-size: 13px; opacity: .8; }
.chip.sel { border-color: #4cd07d; background: #e5fbee; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.big-emoji { font-size: clamp(50px, 14vmin, 90px); line-height: 1; }
#ranking { list-style: none; margin: 8px 0; padding: 0; text-align: left; }
#ranking li { display: flex; align-items: center; gap: 10px; padding: 6px 12px; margin: 5px 0; border-radius: 16px; background: #f1efff; font-weight: 800; font-size: clamp(16px, 4.2vmin, 22px); }
#ranking li.me { background: #fff1b8; }
#ranking .medal { font-size: 28px; width: 36px; text-align: center; }
#ranking .left { margin-left: auto; font-weight: 700; opacity: .7; font-size: .85em; }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-height: 500px) and (orientation: landscape) {
  .hero { display: none; }
  .seat input { height: 48px; }
  .seat .chip { min-height: 48px; }
  #app { display: grid; grid-template-columns: 1fr minmax(0, 46vw); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
  #hud { grid-column: 1 / 3; padding: 3px 8px; gap: 6px; }
  #side { grid-column: 2; grid-row: 2; max-height: none; border-radius: 22px 0 0 0; min-height: 0; }
  #stage { grid-column: 1; grid-row: 2; }
  #me-row { padding: 6px 8px 0; gap: 8px; }
  .card { width: var(--card-w, 50px); }
  #bar { gap: 6px; padding: 4px 6px 6px; }
  #bar .btn { min-width: 100px; }
  .btn { min-height: 48px; padding: 6px 12px; font-size: 16px; }
  .btn.big { min-height: 52px; font-size: 20px; }
  .seat-label { min-width: 64px; max-width: 72px; padding: 2px 4px 3px; }
  .panel { padding: 8px 14px; border-radius: 22px; width: min(640px, 100%); }
  .panel h1 { font-size: 34px; }
  .panel h3 { margin: 3px 0 2px; font-size: 13px; }
  .sub { margin: 0 0 3px; font-size: 14px; }
  .chip { min-height: 48px; min-width: 56px; padding: 3px 8px; border-width: 3px; }
  .chip b { font-size: 18px; }
  .chip small { font-size: 11px; }
  .row { margin-top: 6px; }
  .big-emoji { font-size: 40px; }
  #ranking li { padding: 3px 10px; margin: 3px 0; }
  #combo-list li { padding: 3px 6px; margin: 3px 0; }
  .raise-panel { padding: 6px 12px; }
  #raise-amt { font-size: 32px; min-width: 80px; }
  .raise-row { margin: 3px 0; }
  .raise-sub { display: none; }
}
