:root {
  color-scheme: dark;
  --gold: #e7bd65;
  --gold-soft: #f4dca5;
  --ink: #eaf7f0;
  --muted: #91aa9e;
  --felt: #073d2c;
  --felt-dark: #04271d;
  --panel: rgba(4, 24, 18, .82);
  --danger: #f07878;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background:
    radial-gradient(circle at 50% -20%, #176247 0, transparent 44%),
    linear-gradient(145deg, #020906, #071812 55%, #020b08);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.23'/%3E%3C/svg%3E");
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .13;
  pointer-events: none;
}
.ambient-one { background: #32d693; top: 8%; left: -180px; }
.ambient-two { background: #d8aa4e; right: -190px; bottom: 0; }

.shell { width: min(1040px, 100%); margin: 0 auto; padding: 24px 18px 28px; position: relative; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid rgba(231,189,101,.55);
  color: var(--gold); font-family: Georgia, serif; font-size: 25px; border-radius: 13px;
  background: linear-gradient(145deg, rgba(231,189,101,.17), rgba(255,255,255,.02));
  box-shadow: inset 0 0 18px rgba(231,189,101,.08);
}
.eyebrow { margin: 0 0 2px; color: var(--gold); letter-spacing: .24em; font-size: 9px; font-weight: 800; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(20px, 4vw, 27px); letter-spacing: .13em; font-weight: 500; }

.player-chip { display: flex; align-items: center; gap: 10px; min-width: 158px; padding: 8px 13px 8px 8px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; background: rgba(2,14,10,.72); backdrop-filter: blur(12px); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #102219; background: linear-gradient(145deg, var(--gold-soft), #a87a2f); font-weight: 900; }
.player-chip strong, .player-chip small { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip strong { font-size: 12px; }
.player-chip small { margin-top: 2px; color: var(--gold-soft); font-size: 11px; }

.notice { padding: 18px; border-radius: 16px; display: grid; gap: 6px; margin: 40px auto; max-width: 620px; }
.error-notice { color: #ffd9d9; border: 1px solid rgba(240,120,120,.35); background: rgba(87,20,20,.55); }

.table {
  position: relative;
  min-height: 720px;
  overflow: hidden;
  padding: 20px clamp(14px, 4vw, 38px) 26px;
  border: 1px solid rgba(231,189,101,.28);
  border-radius: 34px;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(25,116,78,.44), transparent 56%),
    linear-gradient(160deg, rgba(9,76,53,.96), rgba(3,38,27,.98));
  box-shadow: 0 38px 90px rgba(0,0,0,.48), inset 0 0 90px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.08);
}
.table::after { content: ""; position: absolute; inset: 11px; border: 1px solid rgba(231,189,101,.13); border-radius: 25px; pointer-events: none; }
.table-glow { position: absolute; width: 70%; height: 260px; left: 15%; top: 18%; background: #38c991; filter: blur(100px); opacity: .08; pointer-events: none; }
.rules-strip { position: relative; z-index: 1; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 26px; color: rgba(234,247,240,.52); font-size: 9px; letter-spacing: .13em; }
.rules-strip b { color: var(--gold); font-weight: 700; }

.hand { position: relative; z-index: 2; width: min(660px, 100%); margin-inline: auto; }
.dealer-hand { margin-top: 32px; min-height: 192px; }
.player-hand { min-height: 205px; margin-top: 10px; }
.hand-heading { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 14px; color: rgba(234,247,240,.68); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.score { display: grid; place-items: center; min-width: 29px; height: 25px; padding: 0 7px; border: 1px solid rgba(231,189,101,.3); border-radius: 8px; color: var(--gold-soft); background: rgba(1,17,12,.5); font-size: 12px; letter-spacing: 0; }
.cards { display: flex; justify-content: center; min-height: 139px; padding-left: 22px; perspective: 900px; }
.card {
  position: relative; width: 88px; height: 128px; margin-left: -22px; flex: 0 0 auto;
  border-radius: 10px; color: #151a17; background: linear-gradient(150deg, #fffef9, #e5e5dc);
  box-shadow: 0 13px 23px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.1);
  transform-origin: 50% 120%;
}
.card.red { color: #a9292f; }
.card .corner { position: absolute; left: 9px; top: 6px; display: grid; justify-items: center; font-family: Georgia, serif; font-weight: 700; font-size: 20px; line-height: .9; }
.card .corner small { font-size: 15px; margin-top: 3px; }
.card .suit-center { position: absolute; inset: 0; display: grid; place-items: center; font-size: 42px; opacity: .9; }
.card.hidden { overflow: hidden; border: 4px solid #e9e1ca; background: repeating-linear-gradient(45deg, #173e31 0 5px, #0c291f 5px 10px); }
.card.hidden::after { content: "M"; position: absolute; inset: 8px; display: grid; place-items: center; border: 1px solid rgba(231,189,101,.55); color: var(--gold); font: 30px Georgia, serif; }
.card.dealing { animation: deal-card .55s cubic-bezier(.16,.8,.24,1.08) both; animation-delay: var(--delay, 0ms); }
@keyframes deal-card { from { opacity: 0; transform: translate(130px,-100px) rotate(16deg) scale(.72); } to { opacity: 1; transform: translate(0,0) rotate(0) scale(1); } }

.result-banner { position: relative; z-index: 4; width: min(500px, 94%); margin: -5px auto 5px; padding: 12px 18px; text-align: center; border-block: 1px solid rgba(231,189,101,.28); background: linear-gradient(90deg, transparent, rgba(1,22,15,.82), transparent); animation: result-in .5s ease both; }
.result-banner p { margin: 0; color: var(--gold); font: 25px Georgia, serif; letter-spacing: .18em; }
.result-banner strong, .result-banner span { display: block; }
.result-banner strong { margin-top: 4px; font-size: 12px; }
.result-banner span { margin-top: 3px; color: var(--gold-soft); font-size: 12px; }
@keyframes result-in { from { opacity: 0; transform: scale(.9); filter: blur(8px); } to { opacity: 1; transform: scale(1); filter: blur(0); } }

.controls { position: relative; z-index: 5; width: min(540px, 100%); margin: 8px auto 0; padding: 18px; border: 1px solid rgba(255,255,255,.09); border-radius: 20px; background: var(--panel); box-shadow: 0 14px 35px rgba(0,0,0,.25); backdrop-filter: blur(14px); }
.controls > label { display: block; margin-bottom: 8px; color: var(--gold); font-size: 9px; letter-spacing: .2em; text-align: center; font-weight: 900; }
.bet-entry { display: grid; grid-template-columns: 62px 1fr 62px; gap: 8px; }
.adjust, .quick-bets button { border: 1px solid rgba(255,255,255,.1); color: var(--ink); background: rgba(255,255,255,.045); border-radius: 10px; cursor: pointer; }
.adjust:hover, .quick-bets button:hover { border-color: rgba(231,189,101,.48); color: var(--gold-soft); }
.amount-wrap { position: relative; }
.amount-wrap input { width: 100%; height: 46px; padding: 0 48px 0 14px; border: 1px solid rgba(231,189,101,.22); outline: none; border-radius: 11px; color: white; background: rgba(0,0,0,.24); text-align: right; font-size: 18px; font-weight: 750; }
.amount-wrap input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(231,189,101,.1); }
.amount-wrap span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; }
.quick-bets { display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; margin-top: 8px; }
.quick-bets button { min-height: 30px; font-size: 10px; }
.primary-action { width: 100%; height: 53px; margin-top: 12px; border: 0; border-radius: 12px; cursor: pointer; color: #142218; background: linear-gradient(145deg, #f0d28e, #b88638); box-shadow: 0 8px 24px rgba(190,140,58,.2); font-weight: 900; letter-spacing: .1em; }
.primary-action small { display: block; margin-top: 1px; font-size: 8px; letter-spacing: .08em; opacity: .67; }
.primary-action:disabled, .game-action:disabled { cursor: wait; filter: grayscale(.5); opacity: .6; }

.action-controls { padding: 13px 16px 16px; }
.current-bet { margin-bottom: 10px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-align: center; }
.current-bet strong { color: var(--gold-soft); }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-action { min-height: 58px; border-radius: 13px; color: white; cursor: pointer; font-weight: 900; letter-spacing: .12em; }
.game-action span { display: block; margin-top: 3px; font-size: 8px; letter-spacing: .04em; opacity: .62; }
.game-action.hit { border: 1px solid rgba(66,204,155,.45); background: linear-gradient(145deg, rgba(21,124,87,.9), rgba(8,72,50,.95)); }
.game-action.stand { border: 1px solid rgba(231,189,101,.45); background: linear-gradient(145deg, rgba(132,94,32,.86), rgba(72,48,16,.95)); }
.play-again { position: relative; z-index: 5; display: block; width: min(260px, 80%); height: 44px; margin: 12px auto 0; border: 1px solid rgba(231,189,101,.45); border-radius: 999px; color: var(--gold-soft); background: rgba(2,20,14,.72); cursor: pointer; }

footer { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 17px; color: #698076; font-size: 10px; letter-spacing: .08em; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #52d6a3; box-shadow: 0 0 9px #52d6a3; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; width: min(420px, calc(100% - 28px)); padding: 13px 17px; border: 1px solid rgba(240,120,120,.4); border-radius: 12px; color: #ffe4e4; background: rgba(57,14,14,.94); box-shadow: 0 16px 38px rgba(0,0,0,.42); text-align: center; font-size: 12px; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }

@media (max-width: 620px) {
  .shell { padding: 14px 10px 20px; }
  .player-chip { min-width: 0; padding-right: 9px; }
  .player-chip strong, .player-chip small { max-width: 105px; }
  .table { min-height: 690px; padding-inline: 10px; border-radius: 24px; }
  .rules-strip { gap: 6px 12px; font-size: 7px; }
  .dealer-hand { margin-top: 27px; min-height: 173px; }
  .player-hand { min-height: 185px; }
  .card { width: 76px; height: 111px; margin-left: -19px; }
  .cards { min-height: 120px; padding-left: 19px; }
  .card .corner { font-size: 17px; }
  .card .suit-center { font-size: 34px; }
  .controls { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
