:root {
  color-scheme: dark;
  --bg: #071a16;
  --panel: rgba(9, 38, 31, .92);
  --panel-2: rgba(18, 61, 50, .92);
  --felt: #0f5948;
  --felt-dark: #0b4136;
  --line: rgba(255,255,255,.12);
  --text: #f4f5ef;
  --muted: #b7c9c1;
  --gold: #e3ba63;
  --red: #c94c56;
  --green: #36b77c;
  --blue: #6fb9dd;
  --shadow: 0 18px 50px rgba(0,0,0,.32);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100dvh; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
.app-shell { min-height: 100dvh; }
.is-busy button { pointer-events: none; }

.landing-screen, .waiting-screen, .admin-screen {
  min-height: 100dvh;
  padding: calc(24px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 10%, rgba(227,186,99,.12), transparent 32%),
    radial-gradient(circle at 85% 85%, rgba(54,183,124,.13), transparent 35%),
    linear-gradient(145deg, #05120f, #0a2b24 58%, #071a16);
}
.hero-panel, .pin-panel, .waiting-panel, .error-panel, .admin-card {
  width: min(100%, 520px);
  background: linear-gradient(180deg, rgba(19,64,52,.94), rgba(8,31,26,.96));
  border: 1px solid rgba(255,255,255,.11);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 30px 24px;
  text-align: center;
}
.brand-mark { width: 94px; height: 94px; margin: 0 auto 16px; border-radius: 50%; border: 1px solid rgba(227,186,99,.5); display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 38px; background: rgba(0,0,0,.17); box-shadow: inset 0 0 30px rgba(0,0,0,.3); }
.brand-mark span:first-child { color: #f5f3e9; transform: translateY(-4px) rotate(-8deg); }
.brand-mark span:last-child { color: #d95661; transform: translateY(4px) rotate(8deg); }
.eyebrow { margin: 0 0 8px; color: var(--gold); text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 800; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(31px, 8vw, 50px); line-height: 1; letter-spacing: -.035em; }
h2 { margin-bottom: 10px; }
.hero-copy, .waiting-copy, .admin-hint { color: var(--muted); line-height: 1.55; }
.version-label { margin: 18px 0 0; color: rgba(255,255,255,.42); font-size: 12px; }

.primary-button, .secondary-button, .action-button {
  border: 0;
  border-radius: 16px;
  min-height: 48px;
  padding: 12px 18px;
  font-weight: 800;
  color: #0a201a;
  background: var(--gold);
  box-shadow: 0 9px 24px rgba(0,0,0,.18);
}
.primary-button:active, .secondary-button:active, .action-button:active { transform: translateY(1px) scale(.995); }
.secondary-button { color: var(--text); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); }
.start-table-button.ready { color: #071a16; background: linear-gradient(180deg, #66d49f, #37b97d); border-color: rgba(255,255,255,.38); box-shadow: 0 0 0 4px rgba(54,183,124,.13), 0 12px 28px rgba(0,0,0,.24); animation: ready-button-pulse 1.55s ease-in-out infinite; }
.ready-light { display: inline-block; width: 9px; height: 9px; margin-right: 9px; border-radius: 50%; background: #f5fff9; box-shadow: 0 0 0 5px rgba(255,255,255,.16); vertical-align: 1px; }
@keyframes ready-button-pulse { 50% { transform: translateY(-1px); box-shadow: 0 0 0 7px rgba(54,183,124,.07), 0 14px 32px rgba(0,0,0,.26); } }
.full { width: 100%; margin-top: 12px; }
.danger-link { margin-top: 14px; border: 0; background: transparent; color: #ff939b; padding: 10px; }

.pin-panel { position: relative; }
.back-button { position: absolute; left: 16px; top: 16px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.06); }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 26px 0; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); }
.pin-dots i.filled { background: var(--gold); border-color: var(--gold); }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-grid button { min-height: 58px; border-radius: 16px; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.06); font-weight: 800; font-size: 20px; }
.pin-grid .pin-clear, .pin-grid .pin-ok { font-size: 13px; }

.admin-screen { place-items: start center; }
.admin-header { width: min(100%, 720px); display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin-header h1 { margin: 0; font-size: 34px; }
.icon-button { border: 1px solid var(--line); background: rgba(255,255,255,.07); color: var(--text); border-radius: 14px; width: 48px; height: 44px; font-weight: 900; }
.admin-card { width: min(100%, 720px); text-align: left; }
.admin-card label { display: block; color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 14px; }
.admin-card input { width: 100%; margin-top: 7px; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 13px 14px; color: var(--text); background: rgba(0,0,0,.18); outline: none; }
.admin-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(227,186,99,.12); }
.setting-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.number-with-unit { position: relative; }
.number-with-unit span { position: absolute; right: 14px; top: 21px; color: var(--muted); }
.number-with-unit input { padding-right: 48px; }
.blind-preview { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 4px 0 10px; display: grid; gap: 6px; }
.blind-preview span { color: var(--muted); line-height: 1.45; font-size: 13px; }
.admin-hint { width: min(100%, 720px); text-align: center; margin-top: 16px; font-size: 13px; }

.waiting-panel h1 { font-size: clamp(27px, 7vw, 42px); line-height: 1.12; }
.waiting-panel h1 span { display: block; color: var(--muted); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; margin: 10px 0; }
.waiting-pulse { width: 78px; height: 78px; border-radius: 50%; margin: 0 auto 18px; display: grid; place-items: center; color: var(--gold); border: 1px solid rgba(227,186,99,.35); background: rgba(0,0,0,.18); font-size: 38px; animation: pulse 1.8s infinite ease-in-out; }
@keyframes pulse { 50% { transform: scale(1.045); box-shadow: 0 0 0 12px rgba(227,186,99,.04); } }
.seat-status { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: rgba(0,0,0,.14); border: 1px solid var(--line); border-radius: 14px; margin: 9px 0; text-align: left; }
.seat-status i { width: 10px; height: 10px; border-radius: 50%; background: #67736e; }
.seat-status i.online { background: var(--green); box-shadow: 0 0 0 4px rgba(54,183,124,.12); }

.game-screen {
  min-height: 100dvh;
  padding: calc(8px + var(--safe-top)) 8px calc(74px + var(--safe-bottom));
  background: linear-gradient(180deg, #061713, #092a23);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.game-header { height: 55px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 920px; margin: 0 auto 7px; }
.header-stat { background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; }
.header-stat span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.header-stat strong { margin-top: 2px; font-size: 15px; white-space: nowrap; }

.poker-table {
  position: relative;
  width: min(100%, 920px);
  min-height: calc(100dvh - 145px - var(--safe-top) - var(--safe-bottom));
  margin: 0 auto;
  border-radius: 46% / 16%;
  border: 7px solid #3b2718;
  outline: 2px solid rgba(227,186,99,.3);
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,.045), transparent 58%),
    repeating-radial-gradient(circle at 30% 20%, rgba(255,255,255,.014) 0 1px, transparent 1px 5px),
    linear-gradient(145deg, var(--felt), var(--felt-dark));
  box-shadow: inset 0 0 60px rgba(0,0,0,.28), 0 12px 35px rgba(0,0,0,.28);
  display: grid;
  grid-template-rows: minmax(118px, .85fr) minmax(180px, 1.25fr) minmax(150px, 1fr) auto;
  overflow: hidden;
}
.player-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; z-index: 2; }
.player-name-row { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; background: rgba(4,22,18,.72); border: 1px solid rgba(255,255,255,.11); border-radius: 18px; padding: 7px 12px; box-shadow: 0 7px 20px rgba(0,0,0,.18); }
.player-name-row div { display: flex; flex-direction: column; }
.player-name-row strong { font-size: 14px; }
.player-name-row small { color: var(--gold); font-size: 12px; }
.own-name-row { margin-top: 7px; }
.dealer-chip { width: 28px; height: 28px; display: none; place-items: center; border-radius: 50%; background: #f3f0df; color: #18211d; font-weight: 900; border: 3px solid #d3ad58; font-size: 12px; }
.dealer-chip.visible { display: grid; }
.player-cards-wrap { position: relative; display: grid; place-items: center; }
.table-bet { position: absolute; left: 50%; z-index: 7; min-width: 88px; min-height: 31px; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 4px; padding: 5px 12px; border-radius: 999px; color: #241903; background: linear-gradient(180deg, #f0cd79, #c9983e); border: 2px solid rgba(255,243,191,.75); box-shadow: 0 7px 18px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.28); font-size: 12px; font-weight: 800; white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.table-bet strong { color: #160f02; font-size: 14px; }
.table-bet.visible { opacity: 1; visibility: visible; }
.table-bet span[aria-hidden] { visibility: hidden; }
.opponent-table-bet { top: calc(100% + 7px); }
.own-table-bet { bottom: calc(100% + 7px); }
.hole-cards { display: flex; align-items: center; justify-content: center; }
.opponent-cards { margin-bottom: -4px; }
.card-slot { position: relative; display: grid; place-items: center; }
.hole-slot { width: clamp(58px, 17vw, 92px); aspect-ratio: 372 / 520; margin: 0 -5px; }
.own-cards .hole-slot { width: clamp(82px, 23vw, 126px); margin: 0 -7px; }
.playing-card { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 8px rgba(0,0,0,.3)); border-radius: 0; }
.pending-board-card, .pending-deal-card { visibility: hidden; }
.dealt-card-reveal { animation: dealt-card-reveal 220ms ease-out both; }
@keyframes dealt-card-reveal { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.own-cards .hole-slot:first-child { transform: rotate(-4deg) translateY(2px); }
.own-cards .hole-slot:last-child { transform: rotate(4deg) translateY(2px); }
.opponent-cards .hole-slot:first-child { transform: rotate(-3deg); }
.opponent-cards .hole-slot:last-child { transform: rotate(3deg); }

.table-center { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; z-index: 1; }
.pot-display { min-width: 78px; height: 48px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(4,24,19,.72); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 8px 20px rgba(0,0,0,.16); margin-bottom: 7px; }
.pot-display span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.pot-display strong { color: var(--gold); font-size: 20px; line-height: 1; }
.community-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(94%, 560px); gap: 3px; align-items: center; }
.board-slot { width: 100%; aspect-ratio: 372 / 520; border: 1px dashed rgba(255,255,255,.18); border-radius: 9px; background: rgba(0,0,0,.08); }
.board-slot:has(img) { border-color: transparent; background: transparent; }
.street-label { margin-top: 6px; min-height: 18px; color: rgba(255,255,255,.62); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; }

.action-zone { min-height: 118px; padding: 7px 12px 12px; display: flex; align-items: center; justify-content: center; z-index: 4; }
.waiting-action, .turn-indicator { background: rgba(4,24,19,.76); border: 1px solid rgba(255,255,255,.11); border-radius: 16px; padding: 12px 18px; text-align: center; font-weight: 800; }
.thinking-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.turn-indicator { display: none; }
.action-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.action-button { min-height: 43px; padding: 9px 13px; color: var(--text); box-shadow: none; }
.action-button.fold { background: rgba(201,76,86,.88); }
.action-button.check { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); }
.action-button.call { background: #377f9f; }
.action-button.raise { background: #b8862c; }
.action-button.allin { background: #7e3845; border: 1px solid rgba(255,255,255,.16); }
.raise-control { position: absolute; z-index: 8; left: 50%; bottom: 112px; transform: translateX(-50%); width: min(92%, 420px); background: rgba(5,28,23,.97); border: 1px solid rgba(255,255,255,.15); border-radius: 20px; box-shadow: var(--shadow); padding: 15px; }
.raise-control[hidden] { display: none; }
.raise-value-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.raise-value-row strong { color: var(--gold); font-size: 24px; }
.raise-control input[type=range] { width: 100%; accent-color: var(--gold); }
.raise-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 9px; }
.raise-quick button { border: 1px solid var(--line); border-radius: 10px; padding: 7px 4px; background: rgba(255,255,255,.06); color: var(--text); font-size: 11px; }

.result-panel { width: min(94%, 520px); background: rgba(5,28,23,.96); border: 1px solid rgba(255,255,255,.15); border-radius: 21px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
.result-panel h2 { font-size: 22px; }
.showdown-lines { display: grid; gap: 4px; margin: 10px 0 13px; color: var(--muted); font-size: 13px; }
.ready-status { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.auto-next-status { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.auto-next-status strong { color: var(--gold); font-size: 18px; }
.game-over-panel { padding: 20px; }

.fullscreen-button, .menu-button {
  position: fixed;
  z-index: 40;
  bottom: calc(12px + var(--safe-bottom));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.16);
  color: var(--text);
  background: rgba(5,27,22,.9);
  box-shadow: 0 8px 22px rgba(0,0,0,.24);
  font-size: 21px;
}
.fullscreen-button { left: 12px; }
.menu-button { right: 12px; font-size: 16px; font-weight: 900; }
.floating-menu-panel { position: fixed; z-index: 60; right: 12px; bottom: calc(66px + var(--safe-bottom)); width: min(86vw, 320px); background: rgba(5,26,21,.98); border: 1px solid rgba(255,255,255,.14); border-radius: 18px; padding: 8px; box-shadow: var(--shadow); }
.floating-menu-panel button { width: 100%; min-height: 44px; border: 0; border-radius: 11px; color: var(--text); background: transparent; text-align: left; padding: 10px 12px; }
.floating-menu-panel button:hover { background: rgba(255,255,255,.07); }

.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(78px + var(--safe-bottom)); transform: translate(-50%, 20px); max-width: min(90vw, 520px); background: rgba(3,18,14,.95); color: var(--text); border: 1px solid rgba(255,255,255,.16); border-radius: 14px; padding: 11px 16px; opacity: 0; pointer-events: none; transition: .22s ease; box-shadow: var(--shadow); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fx-layer { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.flying-card { position: fixed; width: 62px; height: auto; transform: translate(-50%,-50%); animation: fly var(--duration, 400ms) cubic-bezier(.2,.7,.2,1) forwards; filter: drop-shadow(0 10px 9px rgba(0,0,0,.36)); }
.flying-chip { position: fixed; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff4c8; background: #a73743; border: 4px dashed rgba(255,255,255,.82); transform: translate(-50%,-50%); animation: fly var(--duration, 620ms) cubic-bezier(.2,.7,.2,1) var(--delay, 0ms) forwards; box-shadow: 0 6px 12px rgba(0,0,0,.35); font-size: 10px; font-weight: 900; opacity: 0; }
.award-chip { width: 38px; height: 38px; background: #b98a2f; border-style: double; border-width: 5px; }
.amount-chip { width: 44px; height: 44px; font-size: 12px; }
@keyframes fly { from { opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(8deg); opacity: .94; } }
.error-panel p { color: var(--muted); line-height: 1.5; }

@media (min-width: 760px) {
  .game-screen { padding-left: 20px; padding-right: 20px; }
  .poker-table { min-height: calc(100dvh - 145px); grid-template-rows: minmax(115px,.8fr) minmax(210px,1.35fr) minmax(155px,1fr) auto; }
  .own-cards .hole-slot { width: 128px; }
  .opponent-cards .hole-slot { width: 88px; }
  .action-zone { min-height: 104px; }
  .action-button { min-width: 112px; }
  .community-cards { gap: 5px; }
}

@media (max-width: 520px) {
  .game-header { gap: 4px; height: 50px; }
  .header-stat { border-radius: 9px; }
  .header-stat span { font-size: 8px; }
  .header-stat strong { font-size: 13px; }
  .poker-table { border-width: 5px; border-radius: 38% / 10%; grid-template-rows: 112px minmax(155px,1fr) 145px auto; min-height: calc(100dvh - 138px - var(--safe-top) - var(--safe-bottom)); }
  .player-name-row { padding: 5px 9px; min-height: 36px; }
  .player-name-row strong { font-size: 12px; }
  .player-name-row small { font-size: 11px; }
  .table-bet { min-width: 78px; min-height: 26px; padding: 4px 9px; font-size: 11px; }
  .table-bet strong { font-size: 13px; }
  .opponent-table-bet { top: calc(100% + 5px); }
  .own-table-bet { bottom: calc(100% + 5px); }
  .dealer-chip { width: 24px; height: 24px; border-width: 2px; }
  .community-cards { width: 97%; gap: 1px; }
  .board-slot { border-radius: 5px; }
  .pot-display { height: 42px; margin-bottom: 4px; }
  .pot-display strong { font-size: 17px; }
  .action-zone { min-height: 112px; padding-left: 6px; padding-right: 6px; }
  .action-buttons { gap: 5px; }
  .action-button { min-height: 40px; padding: 8px 10px; font-size: 12px; }
  .raise-control { bottom: 105px; }
  .setting-row { grid-template-columns: 1fr; gap: 0; }
}

@media (max-height: 690px) and (max-width: 600px) {
  .game-screen { padding-top: calc(4px + var(--safe-top)); }
  .game-header { height: 44px; margin-bottom: 4px; }
  .poker-table { grid-template-rows: 94px minmax(125px,1fr) 125px auto; min-height: calc(100dvh - 126px - var(--safe-top) - var(--safe-bottom)); }
  .own-cards .hole-slot { width: clamp(68px, 20vw, 92px); }
  .opponent-cards .hole-slot { width: clamp(50px, 14vw, 65px); }
  .action-zone { min-height: 96px; }
  .result-panel { padding: 10px; }
  .result-panel h2 { font-size: 18px; }
}
