/* style.css — Card Arena: arena + Seven of Hearts table. CSS gradients only, no images. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root { --cw: 56px; --ch: 78px; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #eaf6ee; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.09), transparent 30%),
    radial-gradient(ellipse 90% 70% at 50% 108%, #0d3a22 0%, transparent 65%),
    linear-gradient(160deg, #2f8a5f 0%, #1e6b45 55%, #144d31 100%);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.05) 45%, transparent 60%);
}

.screen { position: fixed; inset: 0; }
.hidden { display: none !important; }

button { font-family: inherit; }

/* ================= ARENA ================= */
.stage {
  position: relative; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 1.5rem;
}
.logo { display: inline-flex; align-items: center; gap: .65rem; margin-bottom: .35rem; }
.logo .mark {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.35rem; color: #fff; background: linear-gradient(135deg, #3fae76, #1d6b42);
  box-shadow: 0 6px 16px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.25);
}
h1 { font-size: clamp(1.9rem, 5.5vw, 2.9rem); font-weight: 800; letter-spacing: .02em; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.35); }
.tag { color: #b9e3c9; font-weight: 500; letter-spacing: .14em; font-size: .72rem; text-transform: uppercase; }

.games { display: flex; gap: 1.6rem; justify-content: center; margin-top: 2.6rem; flex-wrap: wrap; }
.game {
  width: clamp(230px, 42vw, 320px); aspect-ratio: 4 / 3; cursor: pointer; position: relative;
  overflow: hidden; text-align: left; border-radius: 24px; padding: 1.2rem 1.3rem; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  box-shadow: 0 18px 38px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .18s ease, box-shadow .18s ease;
}
.game:hover, .game:active { transform: translateY(-6px) scale(1.02); box-shadow: 0 26px 48px rgba(0,0,0,.42), 0 0 0 3px rgba(63,174,118,.65); }
#g-seven {
  background:
    radial-gradient(circle at 84% 14%, rgba(214,56,47,.55), transparent 52%),
    radial-gradient(ellipse at 50% 120%, #0e311d 0%, transparent 60%),
    linear-gradient(160deg, #2b8355 0%, #17503a 60%, #123c26 100%);
}
#g-judgement {
  background:
    radial-gradient(circle at 84% 14%, rgba(120,150,190,.25), transparent 55%),
    linear-gradient(160deg, #4c5e75 0%, #33455c 55%, #232e3b 100%);
}
.wm { position: absolute; right: -14px; bottom: -34px; font-size: clamp(8rem, 16vw, 11rem); line-height: 1; color: rgba(255,255,255,.12); pointer-events: none; }
.chip {
  position: absolute; top: 14px; left: 14px; width: 52px; height: 68px;
  background: linear-gradient(165deg, #fffef8, #f0ead9); border-radius: 9px;
  display: grid; place-items: center; font-size: 1.15rem; font-weight: 800;
  color: #d6382f; box-shadow: 0 8px 16px rgba(0,0,0,.35);
}
#g-judgement .chip { color: #26384b; }
.badge-soon {
  position: absolute; top: 14px; right: 14px; background: #fbbf24; color: #4a3203;
  font-size: .62rem; font-weight: 800; letter-spacing: .08em; padding: 4px 8px; border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}
.game .name { font-size: clamp(1.25rem, 2.6vw, 1.6rem); font-weight: 800; letter-spacing: .01em; text-shadow: 0 2px 10px rgba(0,0,0,.45); }
.game .sub { font-size: .74rem; font-weight: 600; color: rgba(255,255,255,.78); letter-spacing: .1em; margin-top: .3rem; text-transform: uppercase; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
.game.locked { cursor: not-allowed; filter: saturate(.75) brightness(.85); }
.game.locked:hover, .game.locked:active { transform: none; box-shadow: 0 18px 38px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); }

/* popup over the tiles */
.backdrop { display: none; position: fixed; inset: 0; z-index: 20; background: rgba(6,20,12,.55); backdrop-filter: blur(3px); }
.backdrop.show { display: block; }
.picker {
  display: none; position: fixed; left: 50%; top: 50%; z-index: 30;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw); background: rgba(10,40,25,.94); border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px; padding: 1.5rem; box-shadow: 0 18px 44px rgba(0,0,0,.5);
  backdrop-filter: blur(8px); animation: pop .22s ease;
}
.picker.show { display: block; }
@keyframes pop { from { transform: translate(-50%,-50%) scale(.94); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }
.picker h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; color: #fff; margin-bottom: .9rem; text-align: center; }
.player-count { display: flex; align-items: center; justify-content: center; gap: .7rem; margin-bottom: .9rem; }
.pc-label { font-size: .72rem; letter-spacing: .12em; color: #b9e3c9; text-transform: uppercase; }
.pc-opts { display: flex; gap: .4rem; }
.pc-opt {
  width: 34px; height: 30px; border-radius: 9px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.07); color: #fff; font-weight: 700; font-size: .9rem; cursor: pointer;
}
.pc-opt.active { background: linear-gradient(135deg, #3fae76, #1d6b42); border-color: transparent; box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.mode {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: .95rem 1.15rem; margin-bottom: .7rem; border-radius: 14px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06); color: #fff; font-size: .98rem; font-weight: 600; cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.mode:last-of-type { margin-bottom: 0; }
.mode.ready:hover { background: rgba(63,174,118,.28); border-color: #3fae76; transform: translateY(-2px); }
.mode .hint { font-weight: 500; font-size: .68rem; color: #a7cdb6; letter-spacing: .06em; text-transform: uppercase; }
.mode.disabled { opacity: .45; cursor: not-allowed; }
.back { margin-top: 1rem; background: none; border: 0; color: #b9e3c9; font-weight: 600; font-size: .82rem; cursor: pointer; display: block; margin-left: auto; margin-right: auto; }
.back:hover { color: #fff; }

/* ================= TABLE ================= */
.table { position: relative; width: 100%; height: 100%; }

.hud {
  position: absolute; top: calc(6px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  background: rgba(10,40,25,.75); border: 1px solid rgba(255,255,255,.14); padding: 5px 16px;
  border-radius: 999px; font-size: .74rem; letter-spacing: .1em; white-space: nowrap; z-index: 6; backdrop-filter: blur(4px);
}
.hud b { color: #7ee2a8; }
.menu-btn {
  position: absolute; top: calc(6px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 6;
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2);
  background: rgba(10,40,25,.75); color: #b9e3c9; font-size: .8rem; cursor: pointer;
}

/* seats */
.seat { position: absolute; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seat.top { top: calc(46px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); }
.seat.topleft { top: calc(66px + env(safe-area-inset-top, 0px)); left: 14%; transform: translateX(-50%); }
.seat.topright { top: calc(66px + env(safe-area-inset-top, 0px)); right: 14%; transform: translateX(50%); }
.seat.left { left: 2.5%; top: 52%; transform: translateY(-50%); }
.seat.right { right: 2.5%; top: 52%; transform: translateY(-50%); }
.seat.bottom { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); }
.seat .name {
  font-size: .66rem; letter-spacing: .08em; color: #b9e3c9; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; background: rgba(10,40,25,.65); white-space: nowrap;
}
.seat .pts { font-size: .6rem; color: #8fb89c; margin-bottom: 3px; }
.fan { display: flex; position: relative; }
.fan.v { flex-direction: column; }

/* opponent face-down fans */
.fback {
  width: calc(var(--cw) * .74); height: calc(var(--ch) * .74); border-radius: 6px; flex-shrink: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 4px, transparent 4px 8px),
    linear-gradient(135deg, #3fae76, #1d6b42);
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 3px 8px rgba(0,0,0,.35), inset 0 0 0 2px rgba(10,40,25,.5);
}
.fan.h .fback + .fback { margin-left: calc(var(--cw) * -.5); }
.fan.v .fback + .fback { margin-top: calc(var(--ch) * -.68); }
.fan.v .count { top: 0; }
.count {
  position: absolute; top: -10px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px;
  background: #fff; color: #1a4a2e; font-size: .7rem; font-weight: 800; border-radius: 999px;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.4); z-index: 5;
}

/* human hand — face-up fan */
.hand .card {
  width: var(--cw); height: var(--ch); flex-shrink: 0; cursor: pointer; position: relative;
  border-radius: 8px; color: #16301f;
  background:
    radial-gradient(circle at 18% 26%, rgba(0,0,0,.045) 0 1px, transparent 1.4px),
    radial-gradient(circle at 76% 70%, rgba(0,0,0,.035) 0 1px, transparent 1.4px),
    linear-gradient(165deg, #fffef8, #f3edde);
  background-size: 9px 9px, 12px 12px, auto;
  border: 1px solid rgba(0,0,0,.09);
  box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.6);
  transition: transform .16s ease, box-shadow .16s ease;
  animation: dealIn .4s ease backwards;
}
.hand .card + .card { margin-left: calc(var(--cw) * -.62); }
/* face-up cards in side seats (vertical fans) overlap the same way */
.fan.v.hand .card + .card { margin-left: 0; margin-top: calc(var(--ch) * -.72); }
.hand .card.raised { transform: translateY(-14px); box-shadow: 0 10px 22px rgba(0,0,0,.45), 0 0 0 2px #3fae76; }
.hand .card.shake { animation: shake .35s ease; }
/* face cards (J/Q/K): a design, not just a number */
.hand .card .faceglyph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--cw) * .62); font-weight: 800; font-family: Georgia, 'Times New Roman', serif;
  color: inherit; opacity: .9; pointer-events: none;
}
.hand .card .faceglyph::before {
  content: ""; position: absolute; inset: 16% 12%; border: 2px solid currentColor; border-radius: 50%;
  opacity: .35;
}
.hand .card .corner { position: absolute; top: 4px; left: 5px; font-size: calc(var(--cw) * .16); font-weight: 800; line-height: 1.05; text-align: center; }
.hand .card .corner-tr { position: absolute; top: 4px; right: 5px; font-size: calc(var(--cw) * .16); font-weight: 800; line-height: 1.05; text-align: center; }
.hand .card .corner-br { position: absolute; bottom: 4px; right: 5px; font-size: calc(var(--cw) * .16); font-weight: 800; line-height: 1.05; text-align: center; transform: rotate(180deg); }
.hand .card .corner small, .hand .card .corner-tr small, .hand .card .corner-br small { display: block; font-size: .9em; }
.hand .card.red .corner, .hand .card.red .corner-tr, .hand .card.red .corner-br { color: #d6382f; }

/* center piles */
.center {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  display: flex; gap: 14px; z-index: 2;
}
.pile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: calc(var(--cw) * .8); height: calc(var(--ch) * 2.4); }
.pile .plabel { font-size: .6rem; letter-spacing: .1em; color: #b9e3c9; margin-bottom: 2px; }
.pc {
  width: calc(var(--cw) * .58); height: calc(var(--ch) * .58); border-radius: 6px; position: absolute;
  left: 50%; top: 50%; margin-left: calc(var(--cw) * -.29);
  background:
    radial-gradient(circle at 18% 26%, rgba(0,0,0,.045) 0 1px, transparent 1.4px),
    linear-gradient(165deg, #fffef8, #f3edde);
  background-size: 8px 8px, auto;
  border: 1px solid rgba(0,0,0,.09); color: #16301f;
  display: grid; place-items: center; font-size: calc(var(--cw) * .17); font-weight: 800;
  box-shadow: 0 3px 8px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255,255,255,.6);
}
.pc.red { color: #d6382f; }
.pc.anchor { z-index: 2; box-shadow: 0 3px 10px rgba(0,0,0,.4), 0 0 0 2px rgba(63,174,118,.7); }
/* lowest & highest cards of each pile fully visible with green ring emphasis */
.pc.low, .pc.high { z-index: 3; border: 2px solid #7ee2a8; box-shadow: 0 4px 12px rgba(0,0,0,.4), 0 0 10px rgba(126,226,168,.8); }
.pc.new { animation: popIn .22s ease; }
.pc .corner { position: absolute; top: 3px; left: 4px; font-size: calc(var(--cw) * .13); font-weight: 800; line-height: 1.05; text-align: center; }
.pc .corner-br { position: absolute; bottom: 3px; right: 4px; font-size: calc(var(--cw) * .13); font-weight: 800; line-height: 1.05; text-align: center; transform: rotate(180deg); }
.pc.red .corner, .pc.red .corner-br { color: #d6382f; }
.empty-pile {
  width: calc(var(--cw) * .58); height: calc(var(--ch) * .58); border-radius: 6px;
  border: 2px dashed rgba(255,255,255,.25);
  display: grid; place-items: center; color: rgba(255,255,255,.3); font-size: calc(var(--cw) * .24); font-weight: 800;
}

/* turn indicator */
.seat .ring { position: absolute; inset: -10px; border-radius: 18px; pointer-events: none; opacity: 0; }
.seat.active .ring {
  opacity: 1; border: 2px solid #7ee2a8;
  box-shadow: 0 0 18px rgba(126,226,168,.7), inset 0 0 12px rgba(126,226,168,.25);
  animation: pulse 1.2s ease-in-out infinite;
}
.seat .arrow {
  position: absolute; width: 0; height: 0; opacity: 0;
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 12px solid #7ee2a8;
  filter: drop-shadow(0 0 6px rgba(126,226,168,.9));
}
.seat.active .arrow { opacity: 1; animation: bob 1s ease-in-out infinite; }
.seat.top .arrow { bottom: -20px; left: 50%; transform: translateX(-50%); }
.seat.topleft .arrow { bottom: -20px; left: 50%; transform: translateX(-50%); }
.seat.topright .arrow { bottom: -20px; left: 50%; transform: translateX(-50%); }
.seat.left .arrow { right: -18px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.seat.right .arrow { left: -18px; top: 50%; transform: translateY(-50%) rotate(90deg); }
.seat.bottom .arrow { top: -20px; left: 50%; transform: translateX(-50%) rotate(180deg); }
.seat.top.active .arrow, .seat.topleft.active .arrow, .seat.topright.active .arrow { transform: translateX(-50%) translateY(2px); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes bob { 0%, 100% { transform: translate(0,0); } 50% { transform: translate(0,4px); } }
@keyframes dealIn { from { opacity: 0; transform: translateY(24px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

/* flying card clone */
.flying {
  position: fixed; z-index: 35; pointer-events: none;
  transition: transform .45s cubic-bezier(.3,.8,.4,1), opacity .45s ease;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%) translateY(20px);
  background: rgba(10,40,25,.92); border: 1px solid rgba(255,255,255,.2); color: #fff;
  padding: .6rem 1.2rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* per-seat pass indicator */
.pass-pill {
  position: absolute; left: 50%; top: 55%; transform: translateX(-50%);
  background: rgba(10,40,25,.92); border: 1px solid rgba(255,255,255,.2); color: #fff;
  padding: .3rem .7rem; border-radius: 999px; font-size: .7rem; font-weight: 600;
  white-space: nowrap; z-index: 8; animation: popIn .18s ease; pointer-events: none;
}

/* overlay panels (round summary / winner) */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(6,20,12,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.overlay.hidden { display: none; }
.panel {
  width: min(440px, 92vw); background: rgba(10,40,25,.96); border: 1px solid rgba(255,255,255,.14);
  border-radius: 20px; padding: 1.4rem 1.5rem; box-shadow: 0 20px 50px rgba(0,0,0,.55);
  animation: popIn .22s ease; text-align: center;
}
@keyframes popIn { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h2 { font-size: 1.15rem; margin-bottom: 1rem; color: #fff; }
.rows { margin-bottom: 1.1rem; }
.row {
  display: flex; justify-content: space-between; align-items: center; padding: .5rem .8rem;
  border-radius: 10px; background: rgba(255,255,255,.05); margin-bottom: .45rem; font-size: .92rem;
}
.row .add { color: #7ee2a8; font-weight: 700; }
.row.win { background: rgba(63,174,118,.25); border: 1px solid rgba(126,226,168,.5); }
.btn {
  display: inline-block; margin: .3rem; padding: .75rem 1.4rem; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.08); color: #fff;
  font-size: .95rem; font-weight: 700; cursor: pointer;
}
.btn.primary { background: linear-gradient(135deg, #3fae76, #1d6b42); border-color: transparent; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.btn.ghost { background: transparent; }

/* ================= MULTIPLAYER screens ================= */
.mp-wrap {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; padding: 1.5rem;
}
.mp-wrap h2 { font-size: 1.3rem; letter-spacing: .06em; }
.mp-input {
  width: min(320px, 84vw); padding: .8rem 1rem; border-radius: 12px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff; font-size: 1rem; text-align: center; outline: none;
}
.mp-input::placeholder { color: rgba(255,255,255,.4); }
.mp-code { text-transform: uppercase; letter-spacing: .3em; width: min(160px, 40vw); }
.mp-join-row { display: flex; gap: .6rem; align-items: center; }
.mp-divider { font-size: .7rem; letter-spacing: .2em; color: #8fb89c; text-transform: uppercase; }
.mp-msg { min-height: 1.2rem; font-size: .85rem; color: #fca5a5; text-align: center; }
.lobby-code { color: #7ee2a8; letter-spacing: .25em; }
.lobby-players { width: min(320px, 84vw); display: flex; flex-direction: column; gap: .4rem; margin: .4rem 0; }
.lobby-player {
  display: flex; justify-content: space-between; align-items: center; padding: .6rem .9rem;
  border-radius: 10px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); font-size: .95rem;
}
.lobby-player.me { border-color: rgba(126,226,168,.6); background: rgba(63,174,118,.18); }
.host-tag { font-size: .62rem; letter-spacing: .15em; color: #fbbf24; font-weight: 800; }
#lobby-start:disabled { opacity: .45; cursor: not-allowed; }
/* server-driven re-renders must not replay deal animations */
body.mp .card, body.mp .pc { animation: none !important; }

/* confetti */
.confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.piece { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .4; } }
