/* The phone: your hand, held just off the edge of the table. Same room as the table screen:
   felt, gold ink, ivory paper, brass. */
body {
  overflow: hidden;
  touch-action: manipulation;
  background:
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(255, 228, 168, .1), transparent 70%),
    radial-gradient(ellipse 140% 100% at 50% 40%, var(--baize-hi) 0%, var(--baize) 50%, var(--baize-deep) 100%);
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; opacity: .25; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.screen { display: none; flex: 1; flex-direction: column; align-items: center; padding: 22px 16px; min-height: 0; }
.screen.on { display: flex; }

h1 { font-family: var(--display); font-weight: 400; color: var(--ivory); font-size: 52px; letter-spacing: .04em; margin: 8vh 0 2px; }
h2 { font-family: var(--display); font-weight: 400; color: var(--ivory); font-size: 28px; margin: 6px 0 4px; text-align: center; }
.sub { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--gold-ink); text-align: center; margin: 0 0 26px; max-width: 330px; line-height: 1.4; }
.eyebrow { margin: 4px 0 0; font-size: 11px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-ink); }

.field { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 320px; margin-bottom: 16px; font-size: 11px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: var(--gold-ink); }
.field input {
  font-family: var(--serif); font-size: 24px; letter-spacing: 0; text-transform: none; color: var(--ivory);
  padding: 8px 2px 10px; background: transparent; border: 0; border-bottom: 1.5px solid var(--gold-faint); border-radius: 0; outline: none;
}
.field input::placeholder { color: rgba(218, 188, 118, .35); }
.field input:focus { border-bottom-color: var(--brass); }
#room { font-family: var(--num); text-transform: uppercase; letter-spacing: .3em; }

/* Brass plate (primary) and gold-hairline (secondary) buttons */
button.primary, .panel-btn.go {
  font-family: var(--display); font-size: 20px; letter-spacing: .05em; color: #2a1d08;
  background: linear-gradient(180deg, #e8cd88 0%, #c9a257 52%, #a9853f 100%);
  border: 1px solid #6f5522; border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 4px 12px rgba(0, 0, 0, .4);
}
button.primary { width: 100%; max-width: 320px; padding: 14px 22px 16px; margin-top: 14px; cursor: pointer; }
button.primary:active, .panel-btn.go:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 1px 4px rgba(0, 0, 0, .4); }
button.ghost, .panel-btn {
  font-family: var(--ui); font-size: 16px; font-weight: 600; letter-spacing: .03em;
  color: var(--ivory); background: rgba(8, 28, 19, .35); border: 1px solid var(--gold-faint); border-radius: 8px;
  padding: 14px 20px; cursor: pointer;
}
button:disabled { opacity: .4; }

.spinner { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--gold-faint); border-top-color: var(--brass); animation: spin 1s linear infinite; margin: 22vh 0 22px; }
@keyframes spin { to { transform: rotate(360deg); } }
#waitMsg { font-family: var(--serif); font-style: italic; font-size: 17px; text-align: center; color: var(--gold-ink); margin-bottom: 24px; max-width: 300px; }

/* ---------- seat picker: a little drawing of the table ---------- */
.minitable { position: relative; width: min(86vw, 350px); aspect-ratio: 1; margin-top: 12px; }
.mt-felt {
  position: absolute; inset: 24%; border-radius: 16px; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, var(--baize-hi), var(--baize-deep));
  border: 5px solid var(--leather); box-shadow: 0 0 0 1px var(--brass), 0 8px 24px rgba(0, 0, 0, .45), inset 0 0 0 1px var(--brass);
  font-family: var(--display); color: var(--gold-ink); letter-spacing: .3em; font-size: 13px;
}
.seatbtn {
  position: absolute; border-radius: 8px; border: 1px solid var(--gold-faint);
  background: rgba(8, 28, 19, .45); color: var(--ivory); font-family: var(--display); font-size: 16px; line-height: 1.15; cursor: pointer; padding: 4px;
}
.seatbtn small { display: block; font-family: var(--ui); font-size: 10.5px; letter-spacing: .08em; color: var(--gold-ink); margin-top: 2px; }
.minitable[data-game="holdem"] .seatbtn, .minitable[data-game="veto"] .seatbtn { font-size: 14px; }
.minitable[data-game="holdem"] .mt-felt, .minitable[data-game="veto"] .mt-felt { inset: 22% 22%; }
.seatbtn::before {
  content: ''; display: block; width: 12px; height: 12px; margin: 0 auto 3px; border-radius: 50%;
  background: radial-gradient(circle, var(--dot, var(--brass)) 0 50%, transparent 51%), repeating-conic-gradient(var(--ivory) 0 11deg, var(--dot, var(--brass)) 11deg 45deg);
}
.seatbtn.open { border-style: dashed; }
.seatbtn.mine { background: var(--stock); color: var(--paper-ink); border-color: var(--brass); }
.seatbtn.mine small { color: #7a6c58; }
.seatbtn:disabled { opacity: .4; }

/* ---------- game ---------- */
.hud { width: 100%; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.team { display: flex; flex-direction: column; align-items: center; min-width: 76px; }
.team span, .trump span { font-size: 10.5px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: var(--gold-ink); }
.team b { font-family: var(--num); font-weight: 400; font-size: 36px; line-height: 1.05; color: var(--ivory); }
.team em { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--gold-ink); min-height: 1em; }
.team:empty { visibility: hidden; }
.trump { display: flex; flex-direction: column; align-items: center; padding-top: 2px; }
.trump b { font-family: var(--num); font-weight: 400; font-size: 34px; line-height: 1.05; color: var(--ivory); }
.trump b.red { color: #e0666c; }
.trump b.swatch { display: inline-flex; align-items: center; gap: 7px; font-family: var(--display); font-size: 21px; margin-top: 4px; }
.trump b.swatch::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 1.5px var(--ivory); }
.trump:empty { visibility: hidden; }

#whoami { margin-top: 10px; font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--gold-ink); display: flex; align-items: center; gap: 7px; }
#whoami i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1.5px var(--ivory); }

#status { text-align: center; margin: 14px 0 10px; min-height: 64px; }
#statusMain { font-family: var(--display); font-size: 28px; line-height: 1.15; color: var(--ivory); }
#statusSub { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--gold-ink); margin-top: 3px; }
body.myturn #statusMain { color: var(--brass-hi); }

#panel { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.row { display: flex; gap: 10px; width: 100%; justify-content: center; flex-wrap: wrap; }
.panel-btn { flex: 1; min-width: 120px; }
.panel-btn.go { padding: 13px 20px 15px; }
.panel-btn.wide { flex: none; min-width: 220px; }
.panel-btn.suit {
  font-family: var(--num); font-size: 30px; padding: 8px 0 10px; min-width: 0; color: var(--card-black);
  background: var(--stock); border: 0; box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}
.panel-btn.suit.red { color: var(--card-red); }
.panel-btn.suit small { display: block; font-family: var(--ui); font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.panel-btn.fold { color: #f2b0a4; border-color: rgba(242, 176, 164, .4); }
.alone { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-style: italic; color: var(--gold-ink); font-size: 16px; padding: 4px 8px; }
.alone input { width: 20px; height: 20px; accent-color: var(--brass); }
.upcard-mini { display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-style: italic; color: var(--gold-ink); font-size: 15px; }
.upcard-mini .card { --cw: 52px; }

#handWrap { margin-top: auto; width: 100%; display: flex; justify-content: center; padding-bottom: 26px; }
#hand { position: relative; display: flex; justify-content: center; align-items: flex-end; height: calc(min(27vw, 150px) * 1.4 + 40px); padding-top: 34px; }
#hand .card {
  --cw: min(27vw, 150px);
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.2), filter .2s, opacity .2s, margin .2s;
  touch-action: none;
  cursor: pointer;
}
#hand.many .card { --cw: min(22vw, 120px); }
#hand.many { height: calc(min(22vw, 120px) * 1.4 + 40px); }
#hand .card.dim { filter: brightness(.5) saturate(.55); }
#hand .card.sel { box-shadow: 0 0 0 2px var(--brass-hi), 0 12px 30px rgba(0, 0, 0, .5); }
#hand .card.fly { transition: transform .35s ease-in, opacity .35s ease-in; opacity: 0; }
#handHint { text-align: center; font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--gold-ink); min-height: 18px; padding-bottom: 6px; }

#netbar {
  position: fixed; top: env(safe-area-inset-top); left: 50%; transform: translateX(-50%); margin-top: 8px;
  background: var(--stock); color: #8a2a2a; font-size: 13px; font-weight: 700; padding: 6px 14px; border-radius: 6px; z-index: 30;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
/* Toasts are paper slips too */
#toast {
  position: fixed; left: 50%; bottom: 30%; transform: translate(-50%, 16px) rotate(-1deg); opacity: 0; pointer-events: none;
  background: var(--stock); color: var(--paper-ink); font-family: var(--serif); font-style: italic; font-size: 17px; padding: 11px 18px 13px; border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: .25s; text-align: center; max-width: 86vw; z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

/* ---------- Hold'em ---------- */
#board { display: none; gap: 6px; justify-content: center; margin-top: 12px; }
body[data-game="holdem"] #board, body[data-game="veto"] #board { display: flex; }
#board .card, #board .slot { --cw: min(15vw, 64px); }
#board .slot { width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: 5px; border: 1px dashed var(--gold-faint); }
#myHand { text-align: center; font-family: var(--serif); font-style: italic; color: var(--brass-hi); min-height: 20px; margin-top: 8px; font-size: 16px; }
body[data-game="holdem"] #status { margin-top: 6px; min-height: 56px; }
#hand.big .card { --cw: min(38vw, 170px); }
#hand.big { height: calc(min(38vw, 170px) * 1.4 + 40px); }
.raise-amt { display: flex; flex-direction: column; align-items: center; }
.raise-amt small { font-size: 10.5px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: var(--gold-ink); }
.raise-amt b { font-family: var(--num); font-weight: 400; font-size: 40px; color: var(--brass-hi); line-height: 1.1; }
#raiseSlider { width: 100%; accent-color: var(--brass); height: 34px; }
.row.quick .panel-btn { min-width: 0; font-size: 14px; padding: 10px 6px; }

/* ---------- Veto ---------- */
#board .card.top-card { --cw: min(22vw, 92px); transform: rotate(-4deg); }
.panel-btn.call { font-family: var(--display); font-size: 21px; color: var(--paper-ink); background: var(--stock); border: 0; box-shadow: 0 3px 10px rgba(0, 0, 0, .4); }
.panel-btn.catch { color: #f6c9b8; border-color: rgba(246, 201, 184, .5); font-size: 15px; }
.pick { margin: 0; font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--gold-ink); }
.row.colours { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-btn.colour {
  display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0;
  font-family: var(--display); font-size: 19px; color: var(--paper-ink); background: var(--stock); border: 0; box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}
.panel-btn.colour::before { content: ''; width: 16px; height: 16px; border-radius: 3px; background: var(--sw); }

@media (orientation: landscape) and (max-height: 500px) {
  .screen { padding: 8px 16px; }
  #status { margin: 4px 0; min-height: 0; }
  #statusMain { font-size: 22px; }
  #hand .card { --cw: min(15vw, 22vh); }
  #hand { height: calc(min(15vw, 22vh) * 1.4 + 30px); padding-top: 26px; }
  #hand.big .card { --cw: min(18vw, 24vh); }
  #hand.big { height: calc(min(18vw, 24vh) * 1.4 + 30px); }
  #board .card, #board .slot { --cw: min(7vw, 44px); }
  .team b { font-size: 26px; }
}

/* ---------- Go Fish ---------- */
body[data-game="gofish"] #board { display: flex; flex-wrap: wrap; max-width: 100%; }
body[data-game="gofish"] #board .card { --cw: min(9vw, 40px); margin: 0 -4px; }
body[data-game="gofish"] {
  background:
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(200, 245, 255, .12), transparent 70%),
    radial-gradient(ellipse 140% 100% at 50% 40%, #1f7380 0%, #145867 50%, #08303d 100%);
  --gold-ink: rgba(226, 244, 240, .8);
  --gold-faint: rgba(226, 244, 240, .32);
}
.row.ranks { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.panel-btn.rank, .panel-btn.who { min-width: 0; padding: 9px 6px; font-family: var(--num); font-size: 22px; line-height: 1; }
.panel-btn.who { font-family: var(--display); font-size: 17px; flex: 1 1 40%; }
.panel-btn.rank small, .panel-btn.who small { display: block; font-family: var(--ui); font-size: 11px; color: var(--gold-ink); margin-top: 3px; }
.panel-btn.rank.on, .panel-btn.who.on { background: var(--stock); color: var(--paper-ink); border-color: var(--stock); }
.panel-btn.rank.on small, .panel-btn.who.on small { color: #7a6c58; }

#fishing { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 4px; }
#fishing[hidden] { display: none; }
#fishing .steps { width: 100%; }
#fishing .step { margin: 6px 0; display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 18px; color: var(--ivory); opacity: .55; transition: opacity .3s; }
#fishing .step b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--num); font-weight: 400; background: rgba(255, 255, 255, .12); }
#fishing .s1, #fishing.sideways .s2 { opacity: 1; }
#fishing.sideways .s1 { opacity: .55; }
#fishing.sideways .s1 b { background: #8fd7a1; color: #0d3320; }
#fishing .water {
  position: relative; width: 100%; height: 90px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(180deg, transparent 0 38%, rgba(160, 230, 240, .35) 38%, rgba(20, 90, 105, .6) 100%);
}
#fishing .line { position: absolute; left: 50%; top: 0; width: 1.5px; height: 46%; background: rgba(240, 250, 255, .7); }
#fishing .bobber {
  position: absolute; left: calc(50% - 9px); top: 30%; width: 18px; height: 22px; border-radius: 50% 50% 45% 45%;
  background: linear-gradient(180deg, #e8473f 0 50%, #f6f1e6 50%); animation: bobber 1.6s ease-in-out infinite;
}
@keyframes bobber { 50% { transform: translateY(5px); } }
#fishing.sideways .bobber { animation-duration: .5s; }
#fishing.caught .bobber { animation: none; transform: translateY(-70px); transition: transform .35s cubic-bezier(.2, 1.4, .4, 1); }
#fishing .link { background: none; border: 0; color: var(--gold-ink); font-family: var(--serif); font-style: italic; font-size: 15px; text-decoration: underline; cursor: pointer; }

.card.pop-catch {
  --cw: min(34vw, 150px);
  position: fixed; left: 50%; bottom: 30%; z-index: 50; pointer-events: none;
  animation: popcatch 1.4s cubic-bezier(.2, 1, .3, 1) forwards;
}
@keyframes popcatch {
  0% { transform: translate(-50%, 60%) scale(.3) rotate(-20deg); opacity: 0; }
  35% { transform: translate(-50%, -40%) scale(1.15) rotate(8deg); opacity: 1; filter: drop-shadow(0 0 18px rgba(200, 245, 255, .8)); }
  60% { transform: translate(-50%, -30%) scale(1.05) rotate(-3deg); opacity: 1; }
  100% { transform: translate(-50%, 160%) scale(.5) rotate(0); opacity: 0; }
}

/* ---------- Chess ---------- */
body[data-game="chess"] {
  background:
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(255, 220, 170, .08), transparent 70%),
    linear-gradient(180deg, #4b2a17, #33190c);
}
#chessPhone {
  --S: min(11.2vw, 6.4vh, 52px);
  display: grid; grid-template-columns: repeat(8, var(--S)); grid-template-rows: repeat(8, var(--S));
  margin: 6px auto 12px; border: 5px solid #5a3218; border-radius: 4px;
  box-shadow: 0 0 0 1.5px #c9a55a, 0 10px 26px rgba(0, 0, 0, .55);
}
#chessPhone .sq { position: relative; display: grid; place-items: center; }
#chessPhone .sq.light { background: #e7cf9e; }
#chessPhone .sq.dark { background: #8e5b33; }
#chessPhone .sq.last { box-shadow: inset 0 0 0 99px rgba(255, 210, 80, .32); }
#chessPhone .sq.sel { box-shadow: inset 0 0 0 3px #f6d27a, inset 0 0 0 99px rgba(255, 210, 80, .3); }
#chessPhone .sq.check { background: radial-gradient(circle, rgba(230, 40, 30, .9), rgba(230, 40, 30, .3) 50%, transparent 75%), #e7cf9e; }
#chessPhone .sq.dot::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(30, 60, 20, .45); }
#chessPhone .sq.hit::after { content: ''; position: absolute; inset: 5%; border-radius: 50%; border: 3px solid rgba(30, 60, 20, .5); }
.pc { font-family: 'Noto Sans Symbols 2', 'Segoe UI Symbol', 'Apple Symbols', serif; line-height: 1; }
#chessPhone .pc { font-size: calc(var(--S) * .8); pointer-events: none; }
.pc.w { color: #faf3e3; -webkit-text-stroke: 1px #2a2018; text-shadow: 0 2px 3px rgba(0, 0, 0, .5); }
.pc.b { color: #1c1918; -webkit-text-stroke: .8px rgba(245, 232, 205, .65); text-shadow: 0 2px 3px rgba(0, 0, 0, .5); }
.row.promo { display: grid; grid-template-columns: repeat(4, 1fr); }
.panel-btn.piece { min-width: 0; padding: 6px 0; background: var(--stock); border: 0; }
.panel-btn.piece .pc { font-size: 42px; }
body[data-game="chess"] #handWrap, body[data-game="chess"] #handHint { display: none; }
body[data-game="backgammon"] { background: linear-gradient(180deg, #7a4322, #4d2812); }
