@font-face {
  font-family: 'DM Sans';
  src: url('/assets/dm-sans.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: 'Playfair Display';
  src: url('/assets/playfair-display.woff2') format('woff2');
  font-weight: 600 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: 'DM Sans', system-ui, sans-serif;
  --ink: #f7efda;
  --muted: #aebbb0;
  --gold: #efc680;
  --gold-light: #ffe0a4;
  --bg: #0e1a15;
  --panel: #14251e;
  --line: #dfd5a92c;
  --serif: 'Playfair Display', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 315px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .46; }
a { color: var(--gold-light); }
:is(button, a, input, select):focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
#app { min-height: 100svh; }
.initial { display: flex; justify-content: center; align-items: center; gap: 14px; min-height: 95svh; color: var(--muted); }

.masthead {
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: max(8px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) 8px max(32px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: #101d17;
}

.brand { display: inline-flex; grid-column: 1; width: max-content; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 22px/1 var(--serif); letter-spacing: .1em; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid #d5ab666e; border-radius: 10px; color: var(--gold); font: 22px/1 Georgia, serif; background: #273b28; }
.brand-sub { display: block; margin-top: 4px; color: #cec5a4; font: 700 8px/1 'DM Sans', sans-serif; letter-spacing: .26em; }
.header-actions { display: flex; grid-column: 3; justify-content: flex-end; gap: 10px; align-items: center; }
.account { display: flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 4px 8px; border-radius: 10px; border: 1px solid transparent; color: var(--ink); background: transparent; }
.account:hover { border-color: var(--line); }
.account > span:last-child { max-width: 15ch; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.avatar { position: relative; display: grid; place-items: center; flex: none; width: 33px; height: 33px; border-radius: 50%; background: #76543d; color: #fff0cf; font-size: 11px; font-weight: 800; letter-spacing: .05em; overflow: hidden; }
.avatar img { position: absolute; width: 100%; height: 100%; object-fit: cover; }

.button { display: inline-flex; justify-content: center; align-items: center; width: max-content; min-height: 44px; gap: 10px; padding: 8px 16px; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: transparent; font-size: .875rem; font-weight: 750; text-decoration: none; }
.button:not(:disabled):active { transform: translateY(1px); }
.button.secondary { background: #203329; border-color: #ddc98d37; }
.button.secondary:not(:disabled):hover { background: #2c4233; }
.button.quiet { color: var(--muted); padding-inline: 10px; }
.button.quiet:hover { color: var(--ink); background: #e6edc911; }
.button.gold { background: linear-gradient(180deg, #f8d490, #e7b86e); color: #271e12; box-shadow: 0 2px 0 #a27a44; border-color: #f5dba2; }
.button.gold:not(:disabled):hover { background: #ffe0a4; }
.button.cabo-button { color: #ffd5bd; background: #643c32; border-color: #e6957b5c; }
.button.cabo-button:not(:disabled):hover { background: #804b3e; }
input, select { min-height: 44px; min-width: 0; border: 1px solid #d4d2a940; padding: 8px 12px; border-radius: 8px; color: var(--ink); background: #0c1812; }
input::placeholder { color: #92a296; opacity: 1; }
label { font-size: .78rem; color: var(--muted); font-weight: 650; }

.clubhouse, .lobby { width: min(1080px, calc(100% - 48px)); margin: 32px auto 0; }
.hero {
  isolation: isolate;
  display: grid;
  align-items: center;
  position: relative;
  min-height: 415px;
  border: 1px solid #d1b47245;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(ellipse at 77% 39%, #315844, transparent 61%), linear-gradient(115deg, #172a23 12%, #234133 70%, #192f27);
}
.hero::before { content: ''; position: absolute; z-index: -1; inset: 0; background: repeating-linear-gradient(45deg,#e4efb903 0 1px,transparent 1px 3px); }
.hero-copy { position: relative; z-index: 1; padding: 45px clamp(24px, 6vw, 72px); max-width: 65%; }
.eyebrow, .hero-index { margin: 0; font-size: .67rem; font-weight: 800; line-height: 1.3; letter-spacing: .23em; color: var(--gold); }
.eyebrow span { display: inline-block; width: 17px; height: 1px; margin: 0 8px 3px 0; background: var(--gold); }
.hero h1 { margin: 10px 0 16px; font: 650 clamp(44px, 6.8vw, 87px)/.98 var(--serif); letter-spacing: -.055em; }
.hero h1 span { color: var(--gold); }
.hero-lede { margin: 0 0 23px; max-width: 32ch; color: #c4d1c4; font-size: .98rem; line-height: 1.55; }
.hero-cta { min-height: 49px; padding-inline: 18px; gap: 22px; }
.hero-index { position: absolute; right: 20px; bottom: 17px; color: #d9cba592; }
.login-form { display: grid; gap: 7px; }
.login-form > div, .join-row { display: flex; gap: 8px; }
.login-form input { width: min(180px, 42vw); }
.login-form small { color: var(--muted); font-size: .73rem; }

.hero-art { position: absolute; top: 5%; bottom: 6%; left: 47%; right: 4%; perspective: 900px; pointer-events: none; }
.art-orbit { position: absolute; left: 6%; top: 14%; width: 92%; height: 74%; border: 1px solid #d4b67a47; transform: rotate(-19deg) rotateX(29deg); border-radius: 50%; }
.art-orbit-inner { transform: rotate(25deg) rotateX(20deg); left: 10%; width: 84%; border-style: dashed; border-color: #edcf9250; }
.art-star { position: absolute; color: #efd29a; font: 41px Georgia, serif; text-shadow: 0 0 20px #efc68078; }
.star-top { right: 12%; top: 13%; }
.star-bottom { left: 9%; bottom: 17%; font-size: 28px; }
.art-card { --card-angle: 0deg; position: absolute; left: 52%; top: 49%; display: grid; place-items: center; width: clamp(74px, 14vw, 164px); aspect-ratio: 5/7; transform: translate(-50%, -50%) rotate(var(--card-angle)) rotateY(-11deg); border-radius: 10%; border: 2px solid #eed1a1; box-shadow: 0 4px 0 #a98158, 0 18px 38px #080e0bbc, inset 0 0 0 6px #ffffff20; overflow: hidden; }
.art-card span, .art-card small { position: absolute; font-weight: 800; }
.art-card span { top: 9%; left: 11%; font: 700 clamp(12px, 2.4vw, 25px)/1 var(--serif); }
.art-card small { bottom: 11%; font-size: clamp(7px, 1.2vw, 13px); letter-spacing: .2em; }
.art-card b { font: clamp(33px, 7vw, 84px)/1 Georgia, serif; }
.art-card-coral { --card-angle: -24deg; left: 37%; top: 53%; color: #352019; background: linear-gradient(145deg, #f1a383, #ae624e); }
.art-card-green { --card-angle: 22deg; left: 67%; top: 52%; color: #173326; background: linear-gradient(145deg, #d0e6a3, #7a9d6e); }
.art-card-back { --card-angle: -4deg; left: 52%; top: 47%; color: #f9d789; background: repeating-linear-gradient(54deg, #d7b5630d 0 1px, transparent 1px 8px), radial-gradient(ellipse, #395a42, #19372e 69%); border-color: #d4ad65; }
.art-card-back i { position: absolute; width: 69%; aspect-ratio: 1; border: 1px solid #e6c781a0; transform: rotate(45deg); border-radius: 16%; }
.art-card-back b { text-shadow: 0 0 16px #e6ba687c; }

.club-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; margin: 24px 0 0; }
.club-section { min-width: 0; padding: 21px 23px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.section-title h2 { font: 650 1.33rem/1.3 var(--serif); margin: 0; }
.section-title > span { color: var(--gold); font-size: .75rem; }
.empty-state { margin: 13px 0 2px; color: var(--muted); font-size: .86rem; }
.room-list { display: grid; gap: 6px; }
.room-row { display: grid; width: 100%; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; min-height: 52px; padding: 7px; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: #1b2e25; text-align: left; }
.room-row:hover { border-color: var(--line); }
.room-row b, .room-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-row small { color: var(--muted); font-size: .75rem; }
.room-icon { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #e8c98c3a; border-radius: 7px; color: var(--gold); }
.join-section form { display: grid; gap: 7px; }
.join-row input { flex: 1; width: 100%; }
.club-footer { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 25px 0; color: #aebbb0; font-size: .73rem; }
.club-footer span { color: var(--gold); }
.club-footer i { width: 3px; height: 3px; background: #b8c8b5; border-radius: 50%; }

.lobby { width: min(865px, calc(100% - 48px)); }
.back { margin: 0 0 10px -9px; }
.lobby-panel { border: 1px solid #d1b4724a; border-radius: 16px; padding: clamp(18px, 4vw, 40px); background: radial-gradient(ellipse at 95% 0, #2b4b37, transparent 55%), var(--panel); }
.lobby-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.lobby h1 { margin: 0; font: 650 clamp(32px, 5vw, 54px)/1 var(--serif); letter-spacing: -.045em; }
.lobby p { color: var(--muted); margin: 12px 0 0; }
.invite-block { display: grid; gap: 6px; padding: 9px 12px; border: 1px solid #d0b57552; border-radius: 8px; background: #101d17; }
.invite-block span { color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .14em; }
.invite-block strong { font: 750 clamp(.85rem, 2vw, 1.25rem)/1.3 'DM Sans', sans-serif; color: var(--gold-light); letter-spacing: .13em; }
.lobby-seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-block: 20px; }
.lobby-seat { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #172a21; }
.lobby-seat > div { min-width: 0; }
.lobby-seat b, .lobby-seat small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby-seat small { color: var(--muted); font-size: .76rem; margin-top: 3px; }
.lobby-seat .avatar { width: 41px; height: 41px; }
.empty-seat { background: #0c1a1460; border-style: dashed; color: #adbaac; }
.empty-seat .avatar { background: #263d30; color: #a1af9e; font-size: 21px; }
.lobby-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; }
#lobby-status { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .8rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #db9a66; box-shadow: 0 0 0 3px #db9a6625; }
.status-dot.live { background: #a5d38c; box-shadow: 0 0 0 3px #a5d38c25; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.remove-bot {
  flex: none; width: 44px; min-height: 44px; margin-left: auto;
  border: 1px solid transparent; border-radius: 8px;
  color: var(--muted); background: transparent; font-size: 1.25rem;
}
.remove-bot:hover { border-color: var(--line); color: var(--ink); }
.bot-form select { width: 100%; }

#app:has(.game-room) { display: flex; flex-direction: column; height: 100dvh; min-height: 465px; }
.game-meta { display: flex; grid-column: 2; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .15em; white-space: nowrap; }
.game-room { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; position: relative; background: #101b16; }
.game-status { display: flex; position: absolute; z-index: 1; top: 9px; left: 12px; align-items: center; gap: 7px; pointer-events: none; }
.turn-chip { color: #e2eadd; padding: 5px 10px; border-radius: 999px; background: #14251ff2; border: 1px solid #dae4be45; font-size: .75rem; font-weight: 800; }
.your-turn { color: var(--gold-light); border-color: #deb86d88; }
.game-status small { color: #e6d8b9; font-size: .72rem; }
.stage-wrap { position: relative; flex: 1 1 auto; min-height: 225px; }
.table-stage { position: absolute !important; inset: 0; background: radial-gradient(ellipse, #213c2e, #101b16 76%); overflow: hidden; }
.action-dock { z-index: 2; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px max(26px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(26px, env(safe-area-inset-left)); border-top: 1px solid #d8b87640; box-shadow: 0 -5px 22px #0d171292; background: #12211b; }
.dock-info { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.dock-info strong { display: block; font-size: .9rem; }
.dock-info p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.dock-signal { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 1px solid #b59c5e5b; border-radius: 8px; color: var(--gold); background: #233729; }
.dock-controls { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.turn-actions, .slot-groups, .slot-group, .exchange-options { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.slot-group { max-width: 100%; }
.slot-group > span { color: var(--muted); font-size: .72rem; max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 3px; }
.slot { min-width: 44px; min-height: 44px; padding: 4px; border: 1px solid #ddc98d46; border-radius: 7px; color: var(--ink); background: #22372b; font-weight: 750; }
.slot small { color: var(--gold); }
.slot[aria-pressed='true'] { color: #312310; border-color: #f6d6a3; background: #efc680; }
.slot[aria-pressed='true'] small { color: #453014; }
.turn-actions { gap: 7px; }
.exchange-options label { display: grid; gap: 3px; }
.exchange-options select { padding: 4px 7px; }

dialog, .results-panel { border: 1px solid #d9ac6366; border-radius: 13px; color: var(--ink); background: #162a22; box-shadow: 0 18px 60px #060d0ae8; }
dialog { width: min(530px, calc(100% - 28px)); max-height: calc(100dvh - 32px); padding: clamp(16px, 4vw, 26px); }
dialog::backdrop { background: #061009be; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.dialog-head h2, .results-panel h2 { margin: 0; font: 650 clamp(23px, 4vw, 31px)/1.1 var(--serif); }
.dialog-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #203329; font-size: 1.4rem; }
dialog p, .results-panel p { color: #c1cbbf; font-size: .88rem; line-height: 1.5; }
dialog label { display: block; margin-bottom: 6px; }
dialog input { width: 100%; margin-bottom: 10px; }
.dialog-actions, .results-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.rules-content h3 { font-size: .93rem; }
.rules-content dl { display: grid; grid-template-columns: auto 1fr; gap: 9px; margin-bottom: 20px; font-size: .81rem; }
.rules-content dt { color: var(--gold-light); font-weight: 750; }
.rules-content dd { margin: 0; color: var(--muted); }
#results { display: grid; position: absolute; inset: 0; z-index: 1; place-items: center; pointer-events: none; }
#results:not(:empty) { background: #07120c85; }
.results-panel { position: relative; pointer-events: auto; width: min(445px, calc(100% - 28px)); padding: 17px 20px; max-height: 95%; overflow-y: auto; animation: result-in .35s ease-out; }
@keyframes result-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.results-trim { color: var(--gold); font-size: 1.05rem; margin-bottom: 5px; }
.results-actions { flex-wrap: wrap; margin-top: 12px; }
.results-actions span { color: var(--muted); font-size: .8rem; }
.score-table { border-collapse: collapse; width: 100%; }
.score-table th, .score-table td { padding: 6px 5px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.score-table th { text-align: left; font-weight: 650; }
.score-table td, .score-table thead th:not(:first-child) { text-align: right; }
.score-table thead th { color: var(--muted); font-size: .75rem; }
.score-table small { color: var(--gold); font-size: .62rem; }
.notices:not(:empty) { position: fixed; z-index: 10; inset: auto max(13px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) auto; max-width: min(380px, calc(100% - 26px)); padding: 12px 15px; color: var(--ink); border: 1px solid #e8c39173; background: #3a3224; border-radius: 8px; box-shadow: 0 4px 15px #070c09a8; font-size: .86rem; pointer-events: none; }
.fallback { display: grid; gap: 6px; place-content: safe center; padding: 18px; height: 100%; overflow: auto; }
.fallback p { font-size: .78rem; color: var(--muted); }
.fallback-cards { display: flex; gap: 4px; flex-wrap: wrap; }
.fallback-card { width: 44px; min-height: 44px; color: var(--gold-light); background: #214233; border: 1px solid #b99356; border-radius: 7px; }
.fallback-card.revealed { color: #2e241b; background: #f2d9ad; }
.fallback-card:disabled { opacity: .9; }

@media (max-width: 760px) {
  .masthead { min-height: 58px; padding-inline: max(13px, env(safe-area-inset-left)) max(13px, env(safe-area-inset-right)); }
  .header-actions { gap: 2px; }
  .clubhouse, .lobby { width: calc(100% - 28px); margin-top: 18px; }
  .hero { min-height: 370px; }
  .hero-copy { max-width: 78%; }
  .club-grid { gap: 12px; margin-top: 14px; }
  .club-section { padding: 14px; }
  .action-dock { display: grid; gap: 7px; padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .dock-controls { justify-content: flex-start; gap: 7px; }
  .dock-signal { width: 28px; height: 28px; }
  .dock-info { min-width: 0; }
  .game-status { top: 6px; }
}

@media (max-width: 520px) {
  .hero { display: block; min-height: 468px; }
  .hero-copy { max-width: 100%; padding: 27px 21px 20px; }
  .hero h1 { font-size: clamp(46px, 14vw, 65px); }
  .hero h1 br { display: none; }
  .hero-lede { font-size: .91rem; margin-bottom: 14px; }
  .hero-art { top: 57%; left: 21%; right: 18%; bottom: 7%; }
  .art-card { width: clamp(69px, 20vw, 96px); }
  .hero-index { right: 10px; bottom: 9px; font-size: .56rem; }
  .club-grid { grid-template-columns: 1fr; }
  .login-form input { width: auto; flex: 1; }
  .lobby-top { flex-wrap: wrap; }
  .lobby-seats { gap: 7px; }
  .lobby-seat { gap: 7px; padding: 8px; }
  .lobby-seat .avatar { width: 29px; height: 29px; }
  .lobby-seat:has(.remove-bot) > .avatar { display: none; }
  .account > span:last-child:not(.avatar) { display: none; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #app:has(.game-room) { min-height: 350px; }
  #app:has(.game-room) .masthead { min-height: 48px; padding-top: 0; padding-bottom: 0; }
  .stage-wrap { min-height: 190px; }
  .action-dock { display: flex; gap: 8px; padding-block: 5px; }
  .dock-signal { display: none; }
  .dock-info { min-width: 120px; }
  .dock-info p { max-width: 28ch; }
  .dock-controls { justify-content: flex-end; }
  .game-status { top: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
