:root {
  color-scheme: dark;
  --bg: #050b09;
  --panel: rgba(13, 25, 21, .84);
  --panel-strong: #101d19;
  --line: rgba(255, 255, 255, .10);
  --text: #f4f7f5;
  --muted: #9aaba4;
  --green: #65e5a5;
  --green-deep: #17845b;
  --gold: #f5c965;
  --red: #f06974;
  --card-w: 94px;
  --card-h: 134px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(27, 118, 79, .22), transparent 36%),
    radial-gradient(circle at 10% 20%, rgba(24, 86, 67, .16), transparent 28%),
    linear-gradient(145deg, #07100d, #030705 72%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  width: 38vw;
  height: 38vw;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .12;
  pointer-events: none;
  animation: ambientMove 18s ease-in-out infinite alternate;
}

.ambient-a { top: -15vw; left: -8vw; background: #1db477; }
.ambient-b { right: -16vw; bottom: -18vw; background: #d0a342; animation-delay: -7s; }

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 600px;
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr) 28px;
  overflow: hidden;
}

.topbar {
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 3vw, 42px) 8px;
}

.brand, .icon-button, .text-button, .modal-close, .hand-scroll, .log-head button {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
}

.brand { display: inline-flex; align-items: center; gap: 10px; justify-self: start; padding: 0; }
.brand-mark {
  width: 40px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(245, 201, 101, .55);
  border-radius: 8px;
  background: linear-gradient(145deg, #284b3d, #10241c);
  box-shadow: 0 9px 24px rgba(0, 0, 0, .28), inset 0 0 0 3px rgba(255,255,255,.035);
  transform: rotate(-4deg);
}
.brand-mark span { color: var(--gold); font: 700 21px Georgia, serif; }
.brand-copy { display: grid; text-align: left; line-height: 1; gap: 4px; }
.brand-copy b { letter-spacing: .18em; font-size: 14px; }
.brand-copy small { color: var(--muted); letter-spacing: .14em; font-size: 8px; }

.round-chip {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(8, 17, 14, .68);
  color: #dce6e1;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .04em;
  backdrop-filter: blur(12px);
}
.round-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

.top-actions { justify-self: end; display: flex; gap: 8px; }
.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(10, 20, 17, .66);
  transition: .2s var(--ease);
}
.icon-button:hover { border-color: rgba(101,229,165,.35); background: rgba(25, 57, 44, .72); transform: translateY(-1px); }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.game { min-height: 0; display: grid; grid-template-rows: 92px minmax(0, 1fr) 190px; }
.is-lobby .game { opacity: .18; filter: blur(5px); }

.opponents {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(30px, 11vw, 170px);
  padding: 4px 12%;
}

.opponent {
  position: relative;
  min-width: 126px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px 7px 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(10, 20, 17, .5);
  transition: .3s var(--ease);
}
.opponent.active { border-color: rgba(101,229,165,.4); background: rgba(18, 47, 36, .75); box-shadow: 0 0 32px rgba(54,192,128,.11); }
.opponent.defender { border-color: rgba(245,201,101,.34); }
.opponent.finished { opacity: .5; filter: grayscale(.75); }
.bot-avatar, .avatar {
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #253c34, #111d19);
  border: 1px solid rgba(255,255,255,.12);
  color: #d8eee4;
  font-size: 11px;
  font-weight: 800;
}
.bot-avatar.bot-1 { background: linear-gradient(145deg, #5b4430, #251b14); color: #f0ce9a; }
.bot-avatar.bot-2 { background: linear-gradient(145deg, #314c5f, #14222c); color: #a9dcf7; }
.bot-avatar.bot-3 { background: linear-gradient(145deg, #523a59, #241726); color: #e1b8e8; }
.opponent-copy { display: grid; gap: 3px; }
.opponent-copy b { max-width: 78px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.opponent-copy small { color: var(--muted); font-size: 10px; }
.opponent-status { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--green); border: 3px solid #0a1512; opacity: 0; transform: scale(.7); transition: .2s; }
.opponent.active .opponent-status { opacity: 1; transform: scale(1); animation: statusPulse 1.5s infinite; }
.mini-cards { display: flex; margin-left: 2px; }
.mini-cards i { width: 13px; height: 18px; margin-left: -8px; border: 1px solid rgba(255,255,255,.3); border-radius: 3px; background: #183b2d; transform: rotate(var(--r, 0deg)); }
.mini-cards i:first-child { margin-left: 0; }

.table-area { position: relative; min-height: 0; display: grid; place-items: center; padding: 6px 150px 4px; }
.table-area::before {
  content: "";
  position: absolute;
  inset: -56px 7% -42px;
  border: 1px solid rgba(101,229,165,.09);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(35, 116, 80, .13), rgba(7, 20, 15, .02) 62%, transparent 70%),
    repeating-radial-gradient(ellipse at center, transparent 0 80px, rgba(255,255,255,.012) 81px 82px);
  box-shadow: inset 0 0 80px rgba(0,0,0,.22), 0 0 100px rgba(20,107,72,.07);
  pointer-events: none;
}

.deck-zone { position: absolute; z-index: 5; left: clamp(22px, 7vw, 108px); top: 50%; transform: translateY(-50%); width: 126px; display: grid; justify-items: center; gap: 9px; }
.deck-stack { position: relative; width: 124px; height: 140px; }
.deck-card, .trump-card-slot { position: absolute; left: 35px; top: 4px; width: 82px; height: 118px; border-radius: 9px; }
.deck-card { box-shadow: -3px 4px 0 #122a21, -6px 7px 0 #0d2019, -9px 10px 0 #091710, 0 14px 30px rgba(0,0,0,.32); }
.trump-card-slot { left: 2px; top: 23px; transform: rotate(-72deg); filter: brightness(.92); }
.trump-card-slot .playing-card { width: 82px; height: 118px; border-radius: 9px; }
.trump-card-slot .playing-card .rank { font-size: 15px; }
.trump-card-slot .playing-card .center-suit { font-size: 38px; }
.deck-count { position: absolute; right: 0; top: -4px; z-index: 5; min-width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #f1f5f3; color: #0a1612; font-size: 10px; font-weight: 850; border: 3px solid #0c1915; }
.trump-label { padding: 5px 10px; border-radius: 100px; background: rgba(7,15,12,.72); color: #becbc6; border: 1px solid var(--line); font-size: 10px; letter-spacing: .03em; }

.battle-wrap { position: relative; z-index: 3; width: min(750px, 100%); height: 100%; min-height: 260px; display: grid; grid-template-rows: 46px minmax(0, 1fr) 44px; justify-items: center; }
.turn-banner {
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  padding: 7px 13px 7px 8px;
  border: 1px solid rgba(101,229,165,.18);
  border-radius: 13px;
  background: rgba(9, 21, 17, .82);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 34px rgba(0,0,0,.2);
}
.turn-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; background: rgba(101,229,165,.12); color: var(--green); }
.turn-banner > div { display: grid; gap: 1px; }
.turn-banner b { font-size: 12px; }
.turn-banner small { color: var(--muted); font-size: 9px; }

.battlefield { position: relative; width: 100%; min-height: 188px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 18px 26px; padding: 14px 16px; }
.empty-table { display: grid; place-items: center; gap: 10px; color: rgba(210,229,220,.28); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.empty-rings { position: relative; width: 54px; height: 34px; }
.empty-rings span { position: absolute; width: 26px; height: 34px; border: 1px solid rgba(255,255,255,.12); border-radius: 5px; transform: rotate(-15deg); }
.empty-rings span:nth-child(2) { left: 14px; transform: rotate(0); }
.empty-rings span:nth-child(3) { left: 28px; transform: rotate(15deg); }
.card-pair { position: relative; width: 106px; height: 150px; animation: pairIn .35s var(--ease) both; }
.card-pair .playing-card.attack-card { position: absolute; left: 0; top: 0; transform: rotate(var(--attack-rot, -4deg)); }
.card-pair .playing-card.defense-card { position: absolute; left: 26px; top: 26px; z-index: 2; transform: rotate(var(--defense-rot, 6deg)); box-shadow: 0 14px 30px rgba(0,0,0,.32); }
.card-pair.targetable .attack-card { cursor: pointer; box-shadow: 0 0 0 2px var(--gold), 0 10px 24px rgba(0,0,0,.26); }
.card-pair.selected-target .attack-card { transform: rotate(-4deg) translateY(-7px); box-shadow: 0 0 0 3px var(--gold), 0 10px 30px rgba(245,201,101,.2); }
.double-cover-badge { position: absolute; z-index: 4; right: -12px; top: 56px; padding: 4px 7px; border-radius: 10px; background: var(--gold); color: #171109; font-size: 9px; font-weight: 900; box-shadow: 0 5px 16px rgba(0,0,0,.3); }
.ghost-joker { position: absolute; left: 25px; top: 27px; z-index: 1; width: var(--card-w); height: var(--card-h); display: grid; place-items: center; border: 1px dashed rgba(245,201,101,.38); border-radius: 10px; color: rgba(245,201,101,.7); background: rgba(15,25,21,.6); font-size: 26px; transform: rotate(5deg); }

.action-bar { z-index: 10; display: flex; gap: 9px; align-self: end; }
.game-button { min-width: 108px; height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid; border-radius: 12px; cursor: pointer; transition: .2s var(--ease); }
.game-button span { font-size: 16px; }
.game-button b { font-size: 11px; letter-spacing: .02em; }
.game-button.secondary { border-color: rgba(101,229,165,.35); background: rgba(31,122,84,.26); color: #a9f5d0; }
.game-button.danger { border-color: rgba(240,105,116,.35); background: rgba(150,52,61,.25); color: #ffc2c8; }
.game-button:hover { transform: translateY(-2px); filter: brightness(1.15); }

.log-card { position: absolute; z-index: 6; right: clamp(18px, 4vw, 60px); top: 50%; width: 190px; max-height: 174px; transform: translateY(-50%); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(7,15,12,.66); backdrop-filter: blur(10px); }
.log-head { height: 32px; display: flex; align-items: center; justify-content: space-between; padding: 0 9px 0 11px; border-bottom: 1px solid var(--line); color: #b7c5bf; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.log-head button { color: var(--muted); font-size: 16px; }
.game-log { max-height: 140px; overflow: auto; padding: 7px 10px 10px; scrollbar-width: thin; }
.log-entry { display: grid; grid-template-columns: 34px 1fr; gap: 7px; padding: 4px 0; color: #90a39a; font-size: 9px; line-height: 1.35; }
.log-entry time { color: #50665d; font-variant-numeric: tabular-nums; }
.log-entry.new { color: #c8d8d1; animation: logIn .25s ease; }

.player-zone { position: relative; z-index: 20; min-height: 0; padding: 0 clamp(15px, 4vw, 54px) max(8px, env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(4,9,7,.95), rgba(4,9,7,.75) 65%, transparent); }
.player-meta { height: 40px; display: flex; align-items: center; gap: 9px; max-width: 1180px; margin: 0 auto; }
.you-avatar { width: 32px; height: 32px; background: linear-gradient(145deg, #d8ac50, #6d4c15); color: #fff4d7; border-color: rgba(245,201,101,.45); font-size: 9px; }
.player-meta > div:nth-child(2) { display: grid; gap: 1px; }
.player-meta b { font-size: 11px; }
.player-meta small { color: var(--muted); font-size: 9px; }
.role-pill { margin-left: auto; padding: 5px 9px; border-radius: 100px; color: var(--green); background: rgba(101,229,165,.08); border: 1px solid rgba(101,229,165,.18); font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.hand-shell { position: relative; width: min(1180px, 100%); height: 140px; margin: 0 auto; }
.hand { height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: clamp(3px, .65vw, 10px); padding: 2px 40px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-behavior: smooth; }
.hand::-webkit-scrollbar { display: none; }
.hand .playing-card { flex: 0 0 auto; cursor: pointer; transform-origin: 50% 110%; transform: translateY(12px) rotate(var(--fan-rotate, 0deg)); transition: transform .24s var(--ease), filter .2s, opacity .2s, box-shadow .2s; animation: handIn .4s var(--ease) both; animation-delay: calc(var(--card-index, 0) * 26ms); }
.hand .playing-card:hover, .hand .playing-card:focus-visible { z-index: 5; transform: translateY(-5px) rotate(0deg) scale(1.035); box-shadow: 0 18px 34px rgba(0,0,0,.36); outline: none; }
.hand .playing-card.playable { box-shadow: 0 0 0 2px rgba(101,229,165,.55), 0 12px 24px rgba(0,0,0,.3); }
.hand .playing-card.playable::after { content: ""; position: absolute; inset: -5px; border: 1px solid rgba(101,229,165,.28); border-radius: 14px; animation: playablePulse 1.6s ease-in-out infinite; }
.hand .playing-card.unplayable { filter: brightness(.48) saturate(.55); opacity: .76; cursor: default; }
.hand .playing-card.selected { transform: translateY(-12px) rotate(0); box-shadow: 0 0 0 3px var(--gold), 0 20px 35px rgba(0,0,0,.4); }
.hand-scroll { position: absolute; z-index: 9; top: 50%; width: 32px; height: 48px; display: grid; place-items: center; transform: translateY(-40%); border: 1px solid var(--line); border-radius: 11px; background: rgba(9,18,15,.84); color: #c5d2cd; font-size: 24px; opacity: .8; }
.hand-scroll.left { left: 0; }
.hand-scroll.right { right: 0; }

.playing-card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  overflow: hidden;
  border: 1px solid rgba(9,20,16,.35);
  border-radius: 10px;
  background: linear-gradient(145deg, #fffef9, #e8ebe4);
  color: #151b18;
  box-shadow: 0 10px 24px rgba(0,0,0,.26), inset 0 0 0 1px rgba(255,255,255,.75);
  line-height: 1;
}
.playing-card.red { color: #ce3344; }
.playing-card .corner { position: absolute; top: 8px; left: 8px; display: grid; justify-items: center; gap: 1px; z-index: 2; }
.playing-card .corner.bottom { top: auto; left: auto; right: 8px; bottom: 8px; transform: rotate(180deg); }
.playing-card .rank { font: 750 18px Georgia, serif; letter-spacing: -.05em; }
.playing-card .suit-small { font-size: 15px; }
.playing-card .center-suit { position: absolute; inset: 0; display: grid; place-items: center; font: 48px Georgia, serif; filter: drop-shadow(0 3px 2px rgba(0,0,0,.08)); }
.playing-card.is-trump::before { content: "КОЗЫРЬ"; position: absolute; left: 50%; bottom: 7px; z-index: 3; transform: translateX(-50%); color: #846211; font-size: 6px; font-weight: 900; letter-spacing: .12em; }
.playing-card.is-trump { box-shadow: inset 0 0 0 2px rgba(224,178,66,.38), 0 10px 24px rgba(0,0,0,.26); }

.back-card, .playing-card.card-back {
  background-color: #123b2c;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.055) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.055) 75%),
    linear-gradient(-45deg, rgba(255,255,255,.055) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.055) 75%),
    radial-gradient(circle at center, #1e6449, #103325 72%);
  background-size: 10px 10px, 10px 10px, auto;
  border: 3px solid #e7e2d2;
  outline: 1px solid #14241e;
  outline-offset: -5px;
}
.back-emblem, .card-back .back-emblem { position: absolute; inset: 50% auto auto 50%; width: 37px; height: 45px; display: grid; place-items: center; transform: translate(-50%,-50%); border: 1px solid rgba(245,201,101,.55); border-radius: 7px; color: var(--gold); font: 700 21px Georgia, serif; background: rgba(7,21,15,.28); box-shadow: 0 0 0 4px rgba(255,255,255,.035); }

.playing-card.joker { color: #151b18; background: radial-gradient(circle at 50% 36%, #fff, #ecebe4 58%, #d8ddd5); }
.playing-card.joker.red-joker { color: #c93e4d; box-shadow: inset 0 0 0 2px rgba(214,54,70,.3), 0 10px 24px rgba(0,0,0,.28); }
.playing-card.joker.black-joker { color: #17221e; box-shadow: inset 0 0 0 2px rgba(20,39,32,.3), 0 10px 24px rgba(0,0,0,.28); }
.joker-word { position: absolute; left: 8px; top: 9px; writing-mode: vertical-rl; font-size: 7px; font-weight: 900; letter-spacing: .12em; }
.joker-word.right { left: auto; top: auto; right: 8px; bottom: 9px; transform: rotate(180deg); }
.joker-star { position: absolute; inset: 0; display: grid; place-items: center; font-size: 52px; text-shadow: 0 3px 0 rgba(0,0,0,.08); }
.joker-band { position: absolute; left: -12px; right: -12px; top: 58px; height: 20px; transform: rotate(-12deg); background: currentColor; opacity: .08; }

.footer-note { display: grid; place-items: center; color: rgba(173,194,185,.33); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }

.overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: rgba(2,7,5,.74);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
}
.overlay.open { opacity: 1; visibility: visible; }
.overlay > * { transform: translateY(16px) scale(.98); opacity: 0; transition: .38s var(--ease); }
.overlay.open > * { transform: none; opacity: 1; }

.lobby-card {
  width: min(920px, 100%);
  min-height: 540px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(18,36,29,.98), rgba(7,16,13,.98));
  box-shadow: 0 35px 90px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06);
}
.lobby-art { position: relative; overflow: hidden; min-height: 440px; background: radial-gradient(circle at 50% 50%, rgba(41,149,101,.3), transparent 46%), linear-gradient(145deg,#0b2219,#07100d); }
.lobby-art::before { content: ""; position: absolute; inset: 0; opacity: .35; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg,rgba(255,255,255,.025) 1px, transparent 1px); background-size: 32px 32px; mask-image: radial-gradient(circle at center, #000, transparent 72%); }
.hero-card { position: absolute; top: 50%; left: 50%; width: 150px; height: 218px; border-radius: 16px; border: 1px solid rgba(0,0,0,.3); background: linear-gradient(150deg,#fffef8,#e3e7df); color: #18201c; box-shadow: 0 30px 50px rgba(0,0,0,.42), inset 0 0 0 2px rgba(255,255,255,.7); }
.hero-card i, .hero-card em { position: absolute; font: 700 27px Georgia, serif; font-style: normal; }
.hero-card i { top: 14px; left: 15px; }
.hero-card em { right: 15px; bottom: 14px; transform: rotate(180deg); }
.hero-card strong { position: absolute; inset: 0; display: grid; place-items: center; font: 42px Georgia,serif; }
.hero-card.red { color: #d23949; }
.hero-card-a { transform: translate(-91%,-46%) rotate(-18deg); animation: cardFloatA 5s ease-in-out infinite; }
.hero-card-b { z-index: 3; color: #be8b27; transform: translate(-50%,-52%) rotate(-1deg); animation: cardFloatB 5.8s ease-in-out infinite; }
.hero-card-b strong { font: 850 14px ui-sans-serif,system-ui; letter-spacing: .18em; }
.hero-card-c { transform: translate(-7%,-45%) rotate(18deg); animation: cardFloatC 5.4s ease-in-out infinite; }
.hero-glow { position: absolute; left: 50%; top: 56%; width: 270px; height: 50px; transform: translate(-50%,-50%); border-radius: 50%; background: rgba(36,192,127,.26); filter: blur(34px); }

.lobby-content { display: flex; flex-direction: column; justify-content: center; padding: 46px 48px; }
.eyebrow { color: var(--green); font-size: 9px; font-weight: 850; letter-spacing: .18em; }
.lobby-content h1 { margin: 8px 0 8px; font: 750 clamp(40px,5vw,62px)/.95 Georgia,serif; letter-spacing: -.045em; }
.lobby-content h1 span { color: var(--gold); }
.lobby-content > p { margin: 0 0 24px; max-width: 390px; color: var(--muted); font-size: 12px; line-height: 1.6; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset legend { margin-bottom: 8px; color: #d5dfda; font-size: 10px; font-weight: 700; }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-bottom: 18px; }
.segmented button { height: 57px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); color: #889a92; cursor: pointer; transition: .2s; }
.segmented button span { max-width: 24px; color: #778981; font-size: 7px; line-height: .7; letter-spacing: 1px; }
.segmented button b { font-size: 14px; }
.segmented button:hover { background: rgba(255,255,255,.05); }
.segmented button.active { border-color: rgba(101,229,165,.5); background: rgba(101,229,165,.1); color: var(--green); box-shadow: inset 0 0 20px rgba(101,229,165,.04); }
.segmented button.active span { color: var(--green); }
.difficulty-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 22px; }
.difficulty-picker legend { flex-basis: 100%; }
.difficulty-picker label { flex: 1; min-width: 80px; cursor: pointer; }
.difficulty-picker input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-picker span { height: 31px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 9px; font-weight: 700; transition: .2s; }
.difficulty-picker input:checked + span { border-color: rgba(245,201,101,.38); background: rgba(245,201,101,.09); color: var(--gold); }
.start-button { width: 100%; height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 19px; border: 0; border-radius: 13px; color: #0c2118; background: linear-gradient(110deg,#7aefb6,#4dd597); font-weight: 850; cursor: pointer; box-shadow: 0 14px 34px rgba(47,208,139,.17); transition: .2s var(--ease); }
.start-button i { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: rgba(3,22,14,.12); font-style: normal; font-size: 20px; }
.start-button:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 18px 40px rgba(47,208,139,.24); }
.text-button { align-self: center; margin-top: 14px; padding: 4px; color: #8fa198; font-size: 9px; border-bottom: 1px dashed rgba(255,255,255,.18); }

.modal { position: relative; width: min(620px,100%); padding: 38px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: linear-gradient(145deg,rgba(18,34,28,.98),rgba(8,17,14,.99)); box-shadow: 0 30px 80px rgba(0,0,0,.55); }
.modal-close { position: absolute; right: 16px; top: 14px; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 22px; transition: .2s; }
.modal-close:hover { background: rgba(255,255,255,.06); color: white; }
.modal h2 { margin: 7px 0 24px; font: 700 30px Georgia,serif; }
.rules-modal { width: min(760px,100%); }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rules-grid article { min-height: 104px; display: flex; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.rule-number { color: rgba(101,229,165,.48); font: 700 18px Georgia,serif; }
.rules-grid h3 { margin: 0 0 6px; font-size: 11px; }
.rules-grid p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.joker-mini { width: 30px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 5px; background: #edf0ea; font-size: 16px; transform: rotate(-4deg); }
.joker-mini.red-joker { color: var(--red); }
.joker-mini.black-joker { color: #18201c; }
.wide-button { width: 100%; height: 46px; margin-top: 19px; border: 1px solid rgba(101,229,165,.38); border-radius: 12px; background: rgba(101,229,165,.1); color: #a9f5d0; font-weight: 800; font-size: 11px; cursor: pointer; transition: .2s; }
.wide-button:hover { background: rgba(101,229,165,.18); transform: translateY(-1px); }

.settings-modal { width: min(480px,100%); }
.toggle-row { min-height: 66px; display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle-row > span { display: grid; gap: 4px; margin-right: auto; }
.toggle-row b { font-size: 11px; }
.toggle-row small { color: var(--muted); font-size: 9px; }
.toggle-row input { position: absolute; opacity: 0; }
.toggle-row i { position: relative; width: 40px; height: 23px; flex: 0 0 auto; border-radius: 30px; background: #27342f; transition: .2s; }
.toggle-row i::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; border-radius: 50%; background: #94a19b; transition: .25s var(--ease); }
.toggle-row input:checked + i { background: #247b57; }
.toggle-row input:checked + i::after { left: 20px; background: #baf7d8; }

.action-modal { width: min(470px,100%); text-align: center; padding-top: 42px; }
.action-preview { height: 100px; display: grid; place-items: center; margin-bottom: 13px; }
.action-preview .playing-card { transform: rotate(-5deg) scale(.82); }
.action-modal h2 { margin-bottom: 8px; }
.action-modal > p { color: var(--muted); font-size: 10px; line-height: 1.5; }
.modal-actions { display: grid; gap: 8px; margin-top: 21px; }
.action-choice { min-height: 49px; display: flex; align-items: center; gap: 12px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); text-align: left; cursor: pointer; transition: .2s; }
.action-choice:hover { border-color: rgba(101,229,165,.4); background: rgba(101,229,165,.08); }
.action-choice > span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: rgba(101,229,165,.1); color: var(--green); font-size: 17px; }
.action-choice > div { display: grid; gap: 3px; }
.action-choice b { font-size: 10px; }
.action-choice small { color: var(--muted); font-size: 8px; }

.result-modal { width: min(430px,100%); overflow: hidden; text-align: center; }
.result-icon { width: 84px; height: 84px; display: grid; place-items: center; margin: 0 auto 20px; border: 1px solid rgba(245,201,101,.38); border-radius: 24px; background: radial-gradient(circle,#315e49,#14271f); color: var(--gold); font: 40px Georgia,serif; box-shadow: 0 15px 40px rgba(0,0,0,.3); }
.result-modal h2 { margin-bottom: 9px; font-size: 35px; }
.result-modal > p { margin: 0 auto 14px; color: var(--muted); font-size: 11px; }
.result-burst i { position: absolute; width: 4px; height: 35px; left: 50%; top: 60px; border-radius: 4px; background: linear-gradient(var(--gold),transparent); transform-origin: 50% 160px; transform: rotate(calc(var(--n) * 72deg)); opacity: .36; }
.result-burst i:nth-child(1){--n:0}.result-burst i:nth-child(2){--n:1}.result-burst i:nth-child(3){--n:2}.result-burst i:nth-child(4){--n:3}.result-burst i:nth-child(5){--n:4}

.toast-stack { position: fixed; z-index: 200; left: 50%; top: max(18px,env(safe-area-inset-top)); display: grid; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { min-width: 220px; max-width: min(420px,calc(100vw - 30px)); padding: 11px 15px; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; background: rgba(15,29,24,.94); color: #e4eee9; box-shadow: 0 12px 35px rgba(0,0,0,.35); font-size: 10px; text-align: center; animation: toastIn .3s var(--ease), toastOut .3s 2.5s ease forwards; backdrop-filter: blur(12px); }
.toast.error { border-color: rgba(240,105,116,.34); color: #ffc2c8; }
.toast.gold { border-color: rgba(245,201,101,.38); color: #ffe6ab; }

[hidden] { display: none !important; }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }

@keyframes ambientMove { to { transform: translate(12vw,8vh) scale(1.2); } }
@keyframes statusPulse { 50% { box-shadow: 0 0 0 5px rgba(101,229,165,0); } }
@keyframes pairIn { from { opacity: 0; transform: translateY(-14px) scale(.92); } }
@keyframes handIn { from { opacity: 0; transform: translateY(45px) rotate(var(--fan-rotate,0)); } }
@keyframes playablePulse { 50% { opacity: .2; transform: scale(1.03); } }
@keyframes logIn { from { opacity: 0; transform: translateX(6px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes cardFloatA { 50% { transform: translate(-91%,-49%) rotate(-20deg); } }
@keyframes cardFloatB { 50% { transform: translate(-50%,-55%) rotate(1deg); } }
@keyframes cardFloatC { 50% { transform: translate(-7%,-48%) rotate(20deg); } }

@media (max-width: 1050px) {
  :root { --card-w: 82px; --card-h: 117px; }
  .app { grid-template-rows: 68px minmax(0,1fr) 22px; }
  .game { grid-template-rows: 78px minmax(0,1fr) 168px; }
  .table-area { padding-inline: 115px; }
  .log-card { width: 150px; right: 15px; }
  .deck-zone { left: 18px; transform: translateY(-50%) scale(.9); }
  .hand-shell { height: 124px; }
  .battle-wrap { min-height: 220px; }
  .battlefield { min-height: 160px; gap: 12px 18px; }
  .card-pair { width: 93px; height: 132px; }
}

@media (max-width: 760px) {
  :root { --card-w: 72px; --card-h: 103px; }
  body { overflow: hidden; }
  .app { min-height: 510px; grid-template-rows: max(58px,calc(48px + env(safe-area-inset-top))) minmax(0,1fr) 0; }
  .topbar { grid-template-columns: 1fr auto; padding: max(8px,env(safe-area-inset-top)) 12px 4px; }
  .brand-mark { width: 32px; height: 38px; border-radius: 7px; }
  .brand-mark span { font-size: 17px; }
  .brand-copy b { font-size: 11px; }
  .brand-copy small { display: none; }
  .round-chip { position: absolute; left: 50%; transform: translateX(-50%); min-height: 28px; padding: 0 10px; font-size: 9px; }
  .icon-button { width: 36px; height: 36px; border-radius: 11px; }
  .icon-button svg { width: 17px; }
  .top-actions { gap: 5px; }
  .game { grid-template-rows: 67px minmax(0,1fr) 151px; }
  .opponents { gap: 7px; justify-content: space-around; padding: 1px 8px; }
  .opponent { min-width: 0; flex: 0 1 108px; gap: 6px; padding: 5px 6px; border-radius: 11px; }
  .bot-avatar { width: 30px; height: 30px; font-size: 9px; }
  .opponent-copy b { max-width: 57px; font-size: 9px; }
  .opponent-copy small { font-size: 8px; }
  .mini-cards { display: none; }
  .table-area { padding: 0 5px; }
  .table-area::before { inset: -25px 1% -25px; border-radius: 42%; }
  .deck-zone { left: 0; top: 50%; width: 78px; transform: translateY(-44%) scale(.7); transform-origin: left center; }
  .battle-wrap { width: calc(100% - 54px); height: 100%; margin-left: 50px; min-height: 195px; grid-template-rows: 39px minmax(0,1fr) 39px; }
  .turn-banner { min-width: 170px; padding: 5px 9px 5px 6px; border-radius: 10px; }
  .turn-icon { width: 27px; height: 27px; border-radius: 8px; }
  .turn-banner b { font-size: 10px; }
  .turn-banner small { font-size: 8px; }
  .battlefield { min-height: 130px; gap: 6px 9px; padding: 4px; overflow-y: auto; align-content: center; }
  .card-pair { width: 80px; height: 116px; }
  .card-pair .playing-card.defense-card, .ghost-joker { left: 17px; top: 17px; }
  .playing-card .corner { top: 6px; left: 6px; }
  .playing-card .corner.bottom { right: 6px; bottom: 6px; }
  .playing-card .rank { font-size: 14px; }
  .playing-card .suit-small { font-size: 12px; }
  .playing-card .center-suit { font-size: 37px; }
  .playing-card.is-trump::before { font-size: 5px; bottom: 5px; }
  .game-button { min-width: 92px; height: 35px; border-radius: 10px; }
  .game-button b { font-size: 9px; }
  .log-card { display: none !important; }
  .player-zone { padding-inline: 6px; padding-bottom: max(2px,env(safe-area-inset-bottom)); }
  .player-meta { height: 34px; padding-inline: 8px; }
  .you-avatar { width: 27px; height: 27px; }
  .player-meta b { font-size: 9px; }
  .player-meta small { font-size: 7px; }
  .role-pill { font-size: 7px; padding: 4px 7px; }
  .hand-shell { height: 116px; }
  .hand { justify-content: flex-start; gap: 5px; padding-inline: calc(50% - 36px); scroll-snap-type: x proximity; }
  .hand .playing-card { scroll-snap-align: center; transform: translateY(7px); }
  .hand .playing-card:hover { transform: translateY(7px); }
  .hand .playing-card.selected { transform: translateY(-7px); }
  .hand-scroll { display: none; }
  .footer-note { display: none; }
  .lobby-card { width: min(460px,100%); min-height: auto; grid-template-columns: 1fr; border-radius: 22px; }
  .lobby-art { min-height: 190px; }
  .hero-card { width: 88px; height: 128px; border-radius: 10px; }
  .hero-card i, .hero-card em { font-size: 16px; }
  .hero-card i { left: 10px; top: 9px; }
  .hero-card em { right: 10px; bottom: 9px; }
  .hero-card strong { font-size: 26px; }
  .hero-card-b strong { font-size: 8px; }
  .lobby-content { padding: 25px 22px 22px; }
  .lobby-content h1 { font-size: 39px; }
  .lobby-content > p { margin-bottom: 17px; font-size: 10px; }
  .segmented button { height: 48px; }
  .difficulty-picker { margin-bottom: 16px; }
  .start-button { height: 46px; }
  .modal { padding: 29px 20px 22px; border-radius: 20px; }
  .modal h2 { font-size: 25px; }
  .rules-grid { grid-template-columns: 1fr; }
  .rules-grid article { min-height: 82px; }
}

@media (max-height: 690px) and (min-width: 761px) {
  :root { --card-w: 76px; --card-h: 109px; }
  .app { min-height: 520px; grid-template-rows: 62px minmax(0,1fr) 18px; }
  .game { grid-template-rows: 64px minmax(0,1fr) 145px; }
  .hand-shell { height: 112px; }
  .player-meta { height: 32px; }
  .battle-wrap { min-height: 190px; grid-template-rows: 38px minmax(0,1fr) 37px; }
  .battlefield { min-height: 130px; }
  .card-pair { width: 87px; height: 122px; }
  .lobby-card { min-height: 490px; }
}

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