/* ===================================================================
   CHAMELEON — game UI design system
   Mobile-first phone frame (< 900px). The desktop / landscape layout
   lives in the @media(min-width:900px) block near the bottom, so the
   portrait layout is never disturbed by the wide one.
   =================================================================== */
:root {
  /* brand palette — the four game colours drive the whole accent system */
  --red: #ff4d5e;
  --blue: #3d9bff;
  --green: #2fd07f;
  --yellow: #ffce3d;
  --gold: #ffd76b;
  --gold-deep: #ffb43d;

  --ink: #16162a;
  --ink-soft: #5a5a72;
  --cream: #fbf3e0;
  --line: #ececf3;
  --panel: #ffffff;

  /* felt table */
  --felt-1: #1f8a58;
  --felt-2: #157048;
  --felt-3: #0e4d31;

  --grad: linear-gradient(100deg, var(--red), #ff8a3d, var(--yellow), var(--green), var(--blue), #9b5de5);

  /* card geometry — matches the real cards' 0.66 aspect ratio */
  --card-w: 72px;
  --card-h: 109px;
  --card-radius: 8px;

  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px;
  --sh-1: 0 2px 6px rgba(0,0,0,.18);
  --sh-2: 0 8px 22px rgba(0,0,0,.28);
  --sh-3: 0 20px 55px rgba(0,0,0,.45);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', 'Poppins', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 720px at 50% -12%, #26264f, #101019 62%);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4, .home__logo, .hdr__logo { font-family: 'Poppins', 'Inter', sans-serif; }

/* app frame: portrait, mobile-first. Screens stack inside. */
.app {
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 8%, rgba(255,255,255,.10), rgba(255,255,255,0) 55%),
    radial-gradient(140% 120% at 50% 120%, rgba(0,0,0,.30), rgba(0,0,0,0) 60%),
    linear-gradient(180deg, var(--felt-1) 0%, var(--felt-2) 46%, var(--felt-3) 100%);
  box-shadow: 0 0 70px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
}
/* subtle felt grain so the table surface reads as felt, not flat green */
.app::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.rainbow-bar { height: 6px; background: var(--grad); background-size: 200% 100%; flex: 0 0 auto; animation: shift 12s ease infinite; position: relative; z-index: 2; }

.screen { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }
.screen[hidden] { display: none; }
.screen--pad { }
.board { display: flex; flex-direction: column; flex: 1 1 auto; }

@keyframes shift { 0%,100%{background-position:0% 50%} 50%{background-position:100% 50%} }

/* ============================ buttons ============================ */
.btn {
  font-family: inherit; font-weight: 700; cursor: pointer; border: none;
  border-radius: 999px; padding: 9px 16px; font-size: .85rem;
  background: #fff; color: var(--ink);
  transition: transform .12s var(--ease), box-shadow .2s, opacity .2s, background .2s;
  box-shadow: var(--sh-1);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(1px) scale(.98); box-shadow: var(--sh-1); }
.btn:focus-visible { outline: 3px solid rgba(255,215,107,.75); outline-offset: 2px; }
.btn--ghost { background: rgba(255,255,255,.15); color: #fff; box-shadow: none; border: 1px solid rgba(255,255,255,.28); backdrop-filter: blur(3px); }
.btn--ghost:hover { background: rgba(255,255,255,.24); box-shadow: none; }
.btn--go { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #3a2b00; }
.btn--sm { padding: 6px 12px; font-size: .76rem; }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn.hdr-icon, .hdr-icon { padding: 8px 11px; font-size: 1rem; line-height: 1; }
.linklike {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: .8rem; font-weight: 600; color: var(--blue); padding: 3px 6px; border-radius: 6px;
}
.linklike:hover { text-decoration: underline; }

/* ============================ game header ============================ */
.hdr {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 10px 12px 8px; color: #fff;
  background: linear-gradient(180deg, rgba(0,0,0,.22), rgba(0,0,0,0));
}
.scores {
  display: flex; align-items: stretch; gap: 6px; flex: 1 1 auto;
  overflow-x: auto; padding: 2px; scrollbar-width: none;
}
.scores::-webkit-scrollbar { display: none; }
.score-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; line-height: 1.05; padding: 4px 10px; border-radius: var(--r-sm);
  background: rgba(0,0,0,.20); border: 1px solid rgba(255,255,255,.12);
  min-width: 46px; flex: 0 0 auto; transition: background .2s, box-shadow .2s, transform .2s;
}
.score-chip b { font-size: 1.02rem; font-weight: 800; }
.score-chip__name {
  font-size: .58rem; opacity: .85; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 2px;
}
.score-chip__crown { font-size: .66rem; }
.score-chip--me { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.35); }
.score-chip--lead b { color: var(--gold); }
.score-chip--turn {
  background: rgba(255,215,107,.24); border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255,215,107,.55), 0 0 16px rgba(255,215,107,.4);
  animation: turnpulse 1.6s ease-in-out infinite;
}
@keyframes turnpulse { 0%,100%{ box-shadow: 0 0 0 2px rgba(255,215,107,.5), 0 0 12px rgba(255,215,107,.3); } 50%{ box-shadow: 0 0 0 3px rgba(255,215,107,.85), 0 0 22px rgba(255,215,107,.6); } }

/* ============================ opponents zone ============================ */
.zone { padding: 8px 12px; }
.zone--opp { border-bottom: 1px solid rgba(255,255,255,.08); }
.zone__row { display: flex; align-items: center; gap: 12px; }
.opps { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
.opps::-webkit-scrollbar { display: none; }
.opp {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px 7px 8px; border-radius: var(--r-md);
  background: rgba(0,0,0,.16); border: 1px solid rgba(255,255,255,.08);
  flex: 0 0 auto; color: #fff; transition: background .2s, box-shadow .2s, transform .2s;
}
.opp--turn {
  background: rgba(255,215,107,.16); border-color: rgba(255,215,107,.6);
  box-shadow: 0 0 0 2px rgba(255,215,107,.5), 0 6px 18px rgba(0,0,0,.3);
}
.opp__color { flex: 0 0 auto; }
.opp__info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.opp__name { font-weight: 700; font-size: .82rem; display: flex; align-items: center; gap: 5px; }
.opp__fan { display: flex; height: 26px; align-items: flex-start; }
.opp__fan .minicard { width: 18px; height: 26px; margin-left: -11px; flex: 0 0 auto; }
.opp__fan .minicard:first-child { margin-left: 0; }
.opp__fan .minicard img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.opp__meta { font-size: .68rem; opacity: .82; font-weight: 600; }
.opp__dots { display: inline-flex; gap: 3px; }
.opp__dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); opacity: .5; animation: oppdot 1s infinite; }
.opp__dots span:nth-child(2){ animation-delay: .2s; } .opp__dots span:nth-child(3){ animation-delay: .4s; }
@keyframes oppdot { 0%,60%,100%{ opacity: .25 } 30%{ opacity: 1 } }

/* ============================ cards (real art) ============================ */
.pcard {
  position: relative; width: var(--card-w); height: var(--card-h); flex: 0 0 auto;
  transition: transform .16s var(--ease), filter .16s;
}
.pcard img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.45));
  -webkit-user-drag: none; user-select: none;
}
.cardback img { filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }

/* face-down draw-pile with a subtle "deck" of cards behind it */
.pile__slot--stack { position: relative; }
.pile__slot--stack::before, .pile__slot--stack::after {
  content: ""; position: absolute; left: 0; top: 0; width: var(--card-w); height: var(--card-h);
  border-radius: var(--card-radius); background: rgba(0,0,0,.28); z-index: 0;
}
.pile__slot--stack::before { transform: translate(3px, 3px); }
.pile__slot--stack::after { transform: translate(6px, 6px); opacity: .6; }
.pile__slot--stack .cardback { position: relative; z-index: 1; }

/* ---------- Colour Card (designed CSS card — no real photo exists) ---------- */
.ccard {
  position: relative; width: var(--card-w); height: var(--card-h); border-radius: var(--card-radius);
  overflow: hidden; flex: 0 0 auto;
  background:
    linear-gradient(160deg, rgba(255,255,255,.30), rgba(255,255,255,0) 45%),
    linear-gradient(155deg, var(--cc1), var(--cc2) 58%, var(--cc3));
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,.55),
    inset 0 0 0 3.5px rgba(0,0,0,.12),
    0 3px 8px rgba(0,0,0,.4);
}
.ccard--red    { --cc1:#ff7c88; --cc2:#ff4d5e; --cc3:#e0374a; }
.ccard--blue   { --cc1:#68b2ff; --cc2:#3d9bff; --cc3:#2b7de0; }
.ccard--green  { --cc1:#5fdd9c; --cc2:#2fd07f; --cc3:#1fae66; }
.ccard--yellow { --cc1:#ffe07a; --cc2:#ffce3d; --cc3:#f0b41f; }
.ccard__mark {
  position: absolute; inset: 12% 12% 16%;
  background: url(assets/cards/cham-mark.png) center/contain no-repeat;
  opacity: .92; filter: drop-shadow(0 1px 2px rgba(0,0,0,.28));
}
.ccard--yellow .ccard__mark { opacity: 1; }
.ccard__word {
  position: absolute; left: 0; bottom: 5px; width: 100%; text-align: center;
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: .42rem; letter-spacing: .12em;
  text-transform: uppercase; color: rgba(255,255,255,.9); text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.ccard--opp { width: 40px; height: 61px; border-radius: 6px; }
.ccard--opp .ccard__word { display: none; }
.ccard--me { width: 62px; height: 94px; }

/* ============================ centre piles ============================ */
.piles {
  position: relative; margin: auto 0;
  display: flex; justify-content: center; align-items: flex-start; gap: 18px; padding: 12px 0 14px;
}
/* soft table-glow behind the centre piles so the felt feels intentional */
.piles::after {
  content: ""; position: absolute; left: 50%; top: 46%; transform: translate(-50%,-50%);
  width: min(420px, 90%); height: 260px; border-radius: 50%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,255,255,.10), rgba(255,255,255,0) 78%);
}
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile__slot { position: relative; }
.pile__label { color: #eafff4; font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.pile__count { color: #bfe6d0; font-size: .6rem; font-weight: 600; }
.pile__empty { width: var(--card-w); height: var(--card-h); border-radius: var(--card-radius); border: 2px dashed rgba(255,255,255,.32); }
.pile.clickable { cursor: pointer; }
.pile.clickable .pile__slot::before {
  content: ""; position: absolute; inset: -5px; border-radius: 13px; z-index: 3;
  border: 2.5px solid var(--gold); box-shadow: 0 0 16px rgba(255,215,107,.75);
  animation: pulse 1.2s infinite; pointer-events: none;
}
.pile.clickable:hover .pcard { transform: translateY(-4px); }
@keyframes pulse { 0%,100%{ opacity: .5 } 50%{ opacity: 1 } }

/* ============================ status + turn banner ============================ */
.status {
  color: #fff; text-align: center; font-size: .86rem; font-weight: 600;
  padding: 7px 14px; min-height: 36px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(0,0,0,.18); transition: background .3s, box-shadow .3s;
}
.is-myturn .status {
  color: #2a1f00; font-weight: 800;
  background: linear-gradient(180deg, rgba(255,215,107,.95), rgba(255,180,61,.92));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4), 0 3px 14px rgba(255,196,80,.4);
}
.actionbar {
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 4px 12px 2px; min-height: 42px;
}

/* ============================ player hand ============================ */
.zone--me { padding-bottom: 14px; }
.zone__row--me { justify-content: center; gap: 14px; }
.color-wrap { display: flex; align-items: center; gap: 8px; }
.me-color { flex: 0 0 auto; }
.color-label { color: #fff; display: flex; flex-direction: column; line-height: 1.15; }
.color-label__cap { font-size: .58rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; font-weight: 700; }
.color-label b { font-size: 1rem; font-weight: 800; }
.hand { display: flex; justify-content: center; align-items: flex-end; padding: 10px 8px 2px; min-height: 124px; }
.hand .pcard {
  margin-left: -24px;
  transform: translateY(var(--lift,0)) rotate(var(--rot,0deg));
  transform-origin: 50% 118%;
}
.hand .pcard:first-child { margin-left: 0; }
.hand.pickable .pcard:not(.locked):not(.nodiscard) { cursor: pointer; }
.hand.pickable .pcard:not(.locked):not(.nodiscard):hover { transform: translateY(calc(var(--lift,0px) - 12px)) rotate(var(--rot,0deg)); z-index: 5; }
.hand .pcard.sel {
  transform: translateY(-20px) rotate(var(--rot,0deg)) scale(1.05); z-index: 6;
}
.hand .pcard.sel img { filter: drop-shadow(0 12px 20px rgba(0,0,0,.55)); }
.hand .pcard.justdrawn img {
  filter: drop-shadow(0 0 2px var(--gold)) drop-shadow(0 0 7px rgba(255,215,107,.9)) drop-shadow(0 5px 10px rgba(0,0,0,.5));
}
.hand .pcard.locked { opacity: .5; filter: grayscale(.3); cursor: not-allowed; }
.hand .pcard.nodiscard { opacity: .62; cursor: not-allowed; }

/* ============================ overlays / panels ============================ */
.overlay {
  position: absolute; inset: 0; background: rgba(8,8,16,.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 40;
  animation: fadein .22s var(--ease);
}
.overlay[hidden] { display: none; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.panel {
  width: 100%; max-width: 400px; background: var(--panel); border-radius: var(--r-xl); padding: 22px 20px 18px;
  max-height: 92dvh; overflow-y: auto; box-shadow: var(--sh-3);
  animation: popin .28s var(--ease);
}
@keyframes popin { from { transform: translateY(12px) scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }
.panel h2 { font-size: 1.4rem; text-align: center; margin-bottom: 4px; letter-spacing: -.01em; }
.panel h2.win { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel__sub { text-align: center; color: var(--ink-soft); font-size: .84rem; margin-bottom: 14px; }
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: .82rem; }
.score-table th, .score-table td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.score-table th { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table tr.row-me td { font-weight: 800; background: #fff8e2; }
.score-table .pos { color: #12864f; font-weight: 700; }
.score-table .neg { color: #d21f45; font-weight: 700; }
.breakdown { font-size: .7rem; color: var(--ink-soft); margin: 2px 0 12px; line-height: 1.6; }
.breakdown .chip {
  display: inline-block; padding: 2px 7px; border-radius: 7px; margin: 3px 3px 0 0; background: var(--line); font-weight: 600;
}
.breakdown .chip.pos { background: #d6f5e5; color: #12684a; }
.breakdown .chip.neg { background: #ffe0e6; color: #a3122f; }
.panel__actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.panel__actions .btn { flex: 1; padding: 12px; }

/* colour-change target modal */
.cc-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.cc-choices .btn { flex: 1; padding: 13px; }

/* ============================ accounts + leaderboard ============================ */
.account-chip {
  font-family: inherit; font-weight: 700; font-size: .68rem; cursor: pointer;
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.14);
  color: #fff; border-radius: 999px; padding: 5px 12px; line-height: 1.2;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .2s, transform .12s; backdrop-filter: blur(4px);
}
.account-chip:hover { background: rgba(255,255,255,.22); }
.account-chip:active { transform: translateY(1px) scale(.98); }
.account-chip.on { background: rgba(255,215,107,.2); border-color: rgba(255,215,107,.55); color: #ffe8a3; }

.auth-form { display: flex; flex-direction: column; gap: 11px; margin-bottom: 6px; }
.auth-input {
  font-family: inherit; font-size: .95rem; color: var(--ink);
  padding: 12px 13px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: #fafafd; outline: none; transition: border-color .15s, box-shadow .15s;
}
.auth-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,208,127,.2); }
.auth-input::placeholder { color: #9a9ab0; }
.auth-submit { width: 100%; padding: 13px; margin-top: 2px; font-size: .95rem; }
.auth-msg { font-size: .78rem; min-height: 1em; color: var(--ink-soft); text-align: center; line-height: 1.4; }
.auth-msg.err { color: #d21f45; font-weight: 600; }
.auth-msg.ok { color: #12864f; font-weight: 600; }
.auth-alt {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}

.lb-panel { display: flex; flex-direction: column; }
.lb-title {
  font-size: 1.4rem; text-align: center; margin-bottom: 10px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lb-account { margin-bottom: 14px; }
.acct-signed {
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  background: #f6f6fb; border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px;
}
.acct-who { font-size: .82rem; color: var(--ink-soft); text-align: center; line-height: 1.4; }
.acct-who b { color: var(--ink); }
.acct-rank { font-size: .82rem; opacity: .95; margin: 1px 0 2px; font-weight: 700; color: var(--ink); }
.acct-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lb-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; max-height: 46dvh; overflow-y: auto; }
.lb-row {
  display: grid; grid-template-columns: 34px 1fr 44px 48px 44px; align-items: center;
  gap: 6px; padding: 9px 10px; border-radius: var(--r-sm); background: #f7f7fb; font-size: .82rem;
}
.lb-row--head { background: transparent; font-size: .6rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 700; padding: 2px 10px; }
.lb-row--me { background: linear-gradient(180deg,#fff7d9,#ffeeb0); box-shadow: inset 0 0 0 1.5px var(--yellow); }
.lb-rank { font-weight: 800; text-align: center; }
.lb-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name em { font-style: normal; font-weight: 600; color: var(--ink-soft); font-size: .72rem; }
.lb-tier { opacity: .8; font-weight: 700; font-size: .66rem; white-space: nowrap; }
.lb-wins { text-align: right; font-weight: 800; color: #12864f; }
.lb-best { text-align: right; font-weight: 700; color: var(--ink); }
.lb-games { text-align: right; color: var(--ink-soft); }
.lb-empty { text-align: center; color: var(--ink-soft); font-size: .85rem; padding: 24px 8px; line-height: 1.5; }

/* ============================ shared sub-screens ============================ */
.subhdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; color: #fff; gap: 8px; flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,0));
}
.subhdr__title { font-size: 1.1rem; font-weight: 800; letter-spacing: .01em; }
.subhdr__spacer { width: 40px; }
.empty-note { color: #eafff4; text-align: center; font-size: .86rem; padding: 26px 16px; line-height: 1.6; opacity: .95; }

/* ============================ HOME / landing ============================ */
.home { padding: 6px 20px 18px; color: #fff; text-align: center; }
.home__top { display: flex; justify-content: flex-end; padding: 4px 0 0; }
.home__hero { display: flex; flex-direction: column; align-items: center; margin: auto 0 6px; }
.home__lizard { font-size: 4.6rem; line-height: 1; filter: drop-shadow(0 10px 20px rgba(0,0,0,.5)); animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0) rotate(-4deg) } 50%{ transform: translateY(-9px) rotate(4deg) } }
.home__logo {
  font-size: 2.8rem; font-weight: 800; letter-spacing: .06em; margin-top: 6px;
  background: var(--grad); background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shift 9s ease infinite; text-shadow: 0 2px 22px rgba(0,0,0,.3);
}
.home__tag { color: #e6fff2; font-size: .92rem; max-width: 320px; margin: 8px auto 0; line-height: 1.55; opacity: .95; }
.home__menu { display: flex; flex-direction: column; gap: 11px; margin: 14px 0 8px; }
.home__row { display: flex; gap: 11px; }
.home__foot { color: #cdeede; font-size: .72rem; line-height: 1.5; margin-top: auto; padding-top: 12px; opacity: .9; }
.home__foot b { color: var(--gold); }

.ai-setup {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 4px;
  color: #fff;
}
.ai-setup__label { font-weight: 700; font-size: .82rem; opacity: .9; }
.ai-setup__select {
  font: inherit; font-weight: 700; font-size: .85rem; padding: 8px 12px; border-radius: var(--r-sm);
  border: 1.5px solid rgba(255,255,255,.35); background: rgba(255,255,255,.16); color: #fff; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23fff' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px;
}
.ai-setup__select option { color: #16162a; }

.bigbtn {
  display: flex; align-items: center; gap: 14px; width: 100%; cursor: pointer;
  border: none; border-radius: var(--r-lg); padding: 15px 16px; text-align: left;
  font-family: inherit; color: var(--ink); background: #fff;
  box-shadow: var(--sh-2); transition: transform .12s var(--ease), box-shadow .2s;
}
.bigbtn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.34); }
.bigbtn:active { transform: translateY(1px) scale(.99); box-shadow: var(--sh-1); }
.bigbtn__icon {
  font-size: 1.7rem; width: 46px; height: 46px; flex: 0 0 auto; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.06);
}
.bigbtn__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.bigbtn__text b { font-size: 1.02rem; font-weight: 800; }
.bigbtn__text small { font-size: .74rem; color: var(--ink-soft); }
.home__row .bigbtn { flex: 1; padding: 14px 12px; gap: 11px; min-width: 0; }
.home__row .bigbtn__icon { width: 40px; height: 40px; font-size: 1.4rem; }
.home__row .bigbtn__text b { font-size: .96rem; }
.bigbtn--play { background: linear-gradient(120deg, var(--gold), var(--gold-deep)); }
.bigbtn--play .bigbtn__text small { color: #6a4b00; }
.bigbtn--play .bigbtn__icon { background: rgba(255,255,255,.5); }
.bigbtn--match { background: linear-gradient(135deg, #3d9bff, #5ad1c8); color: #052438; }
.bigbtn--match .bigbtn__text small { color: #08405c; }
.bigbtn--match .bigbtn__icon { background: rgba(255,255,255,.35); }
.bigbtn--friends { background: linear-gradient(135deg, #ff7aa2, #ff4d5e); color: #fff; }
.bigbtn--friends .bigbtn__text small { color: rgba(255,255,255,.88); }
.bigbtn--friends .bigbtn__icon { background: rgba(255,255,255,.25); }
.bigbtn--board { background: #fff; }
.bigbtn--howto { background: linear-gradient(135deg, #b98bff, #7c5cff); color: #fff; }
.bigbtn--howto .bigbtn__text small { color: rgba(255,255,255,.86); }
.bigbtn--howto .bigbtn__icon { background: rgba(255,255,255,.24); }

.shoplink {
  display: flex; align-items: center; gap: 12px; text-decoration: none; cursor: pointer;
  border-radius: var(--r-md); padding: 11px 14px; margin-top: 2px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.18); color: #fff;
  transition: background .2s, transform .12s, border-color .2s;
}
.shoplink:hover { background: rgba(0,0,0,.32); border-color: rgba(255,255,255,.3); transform: translateY(-1px); }
.shoplink__icon { font-size: 1.2rem; }
.shoplink__text { display: flex; flex-direction: column; line-height: 1.2; text-align: left; flex: 1 1 auto; }
.shoplink__text b { font-size: .84rem; font-weight: 700; }
.shoplink__text small { font-size: .68rem; opacity: .78; }
.shoplink__arrow { font-size: 1.1rem; opacity: .8; }

/* ============================ LOGIN ============================ */
.login__body { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 20px 26px; }
.login__lizard { font-size: 3rem; margin-bottom: 6px; filter: drop-shadow(0 6px 16px rgba(0,0,0,.45)); }
.auth-card { width: 100%; max-width: 360px; background: #fff; border-radius: var(--r-xl); padding: 22px 20px 18px; box-shadow: var(--sh-3); }
.auth-card h2 { text-align: center; font-size: 1.4rem; margin-bottom: 4px; }

/* ============================ FRIENDS ============================ */
.friends-body { flex: 1 1 auto; overflow-y: auto; padding: 6px 14px 22px; }
.fr-search { display: flex; gap: 8px; margin-bottom: 10px; }
.fr-search .auth-input { flex: 1; }
.fr-section-title { color: #eafff4; font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 800; margin: 16px 2px 7px; opacity: .9; }
.fr-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 7px; color: #fff;
}
.fr-name { font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.fr-pending { font-size: .72rem; color: var(--gold); font-weight: 700; }

/* ============================ HOW TO PLAY ============================ */
.howto-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 26px; }
.howto-hero { text-align: center; color: #fff; padding: 6px 4px 14px; }
.howto-hero__mark { font-size: 2.8rem; filter: drop-shadow(0 6px 14px rgba(0,0,0,.5)); }
.howto-hero__title { font-size: 1.35rem; font-weight: 800; margin: 6px 0 6px; }
.howto-hero__sub { font-size: .86rem; line-height: 1.55; color: #e6fff2; max-width: 460px; margin: 0 auto; opacity: .95; }
.howto-hero__sub b { color: var(--gold); }

.rule {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start;
  background: #fff; border-radius: var(--r-lg); padding: 15px 16px; margin-bottom: 12px; box-shadow: var(--sh-1);
}
.rule__step { display: flex; justify-content: center; }
.rule__n {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins'; font-weight: 800; font-size: .95rem; color: #fff;
  background: linear-gradient(140deg, var(--green), var(--blue));
}
.rule__main h4 { font-size: 1.02rem; margin-bottom: 5px; color: var(--ink); }
.rule__main p { font-size: .84rem; line-height: 1.55; color: var(--ink-soft); }
.rule__main p b { color: var(--ink); }
.rule__note { margin-top: 8px; font-size: .78rem; background: #f6f6fb; border-radius: var(--r-sm); padding: 8px 10px; }
.rule__cards { display: flex; align-items: center; gap: 6px; margin: 12px 0 2px; flex-wrap: wrap; }
.rule__cards--out { gap: 5px; }
.rule__plus, .rule__eq { font-weight: 800; color: var(--ink-soft); font-size: .9rem; margin: 0 3px; }
.rule__eq { font-size: .82rem; color: var(--green); }
.cardback-mini { width: 40px; height: 61px; flex: 0 0 auto; }
.cardback-mini img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.pcard-mini { width: 46px; height: 70px; flex: 0 0 auto; }
.pcard-mini img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 2px 5px rgba(0,0,0,.28)); }
.ccard--guide { width: 44px; height: 67px; }
.ccard--guide .ccard__word { font-size: .34rem; }

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 2px; }
.choice {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  background: #f6f6fb; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 8px;
}
.choice .cardback-mini { width: 34px; height: 52px; margin-bottom: 2px; }
.choice b { font-size: .74rem; }
.choice small { font-size: .66rem; color: var(--ink-soft); line-height: 1.35; }

.scorelist { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 6px 0 2px; }
.scorelist li { display: flex; align-items: center; gap: 9px; font-size: .84rem; color: var(--ink-soft); line-height: 1.4; }
.scorelist li b { color: var(--ink); }
.tag {
  flex: 0 0 auto; min-width: 30px; height: 24px; padding: 0 8px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .74rem;
}
.tag--pos { background: #d6f5e5; color: #12684a; }
.tag--neg { background: #ffe0e6; color: #a3122f; }
.tag--bonus { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #3a2b00; font-size: .7rem; }

.howto-guide { background: #fff; border-radius: var(--r-lg); padding: 15px 16px; margin-bottom: 14px; box-shadow: var(--sh-1); }
.howto-guide__title { font-size: 1.05rem; margin-bottom: 12px; }
.cardguide { display: flex; flex-direction: column; gap: 12px; }
.cardguide__item { display: flex; align-items: center; gap: 13px; }
.cardguide__item figcaption { display: flex; flex-direction: column; gap: 2px; }
.cardguide__item figcaption b { font-size: .88rem; }
.cardguide__item figcaption span { font-size: .76rem; color: var(--ink-soft); line-height: 1.4; }
.howto-cta { width: 100%; padding: 14px; font-size: 1rem; margin-top: 4px; }

/* ============================ MULTIPLAYER waiting ============================ */
.mp-panel { text-align: center; }
.mp-spinner { font-size: 3rem; animation: bob 2.2s ease-in-out infinite; margin-bottom: 6px; }
.mp-panel h2 { font-size: 1.35rem; }
.mp-wait-note { color: var(--ink-soft); font-size: .82rem; font-weight: 600; text-align: center; padding: 6px 0; }

/* ============================ invite banner ============================ */
.invite-banner {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(120deg, var(--gold), var(--gold-deep)); color: #3a2b00;
  border-radius: var(--r-md); padding: 11px 13px; box-shadow: var(--sh-3);
  animation: dropIn .3s var(--ease);
}
@keyframes dropIn { from { transform: translateY(-14px); opacity: 0 } to { transform: none; opacity: 1 } }
.invite-banner__text { font-size: .84rem; font-weight: 700; line-height: 1.35; }
.invite-banner__actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ============================ small phones ============================ */
@media (max-height: 720px) {
  :root { --card-w: 64px; --card-h: 97px; }
}

/* =====================================================================
   DESKTOP / LANDSCAPE (>= 900px). Everything below is scoped here so the
   mobile-portrait layout above is untouched. The frame widens into a felt
   table, cards scale up, and each screen gets a real wide layout.
   ===================================================================== */
@media (min-width: 900px) {
  :root { --card-w: 88px; --card-h: 133px; --card-radius: 11px; }

  .app { max-width: 1120px; }
  .rainbow-bar { height: 7px; }

  .hdr { padding: 16px 28px 12px; }
  .scores { gap: 10px; }
  .score-chip { padding: 6px 16px; min-width: 58px; }
  .score-chip b { font-size: 1.18rem; }
  .score-chip__name { font-size: .62rem; }
  .btn { font-size: .9rem; padding: 10px 18px; }
  .btn.hdr-icon, .hdr-icon { padding: 9px 12px; font-size: 1.05rem; }
  .subhdr { padding: 16px 30px; }
  .subhdr__title { font-size: 1.35rem; }

  /* ---------- HOME: two-column landing ---------- */
  .home {
    display: grid; grid-template-columns: 1.05fr .95fr;
    grid-template-areas: "hero menu" "foot foot";
    align-content: center; justify-items: center; column-gap: 56px; row-gap: 14px;
    padding: 24px 60px 30px; position: relative;
  }
  .home__top { position: absolute; top: 20px; right: 28px; width: auto; padding: 0; }
  .home__hero { grid-area: hero; margin: 0; align-items: flex-start; justify-content: center; text-align: left; }
  .home__lizard { font-size: 7rem; }
  .home__logo { font-size: 4.6rem; margin-top: 12px; }
  .home__tag { font-size: 1.16rem; max-width: 440px; margin: 18px 0 0; }
  .home__menu { grid-area: menu; margin: 0; align-self: center; width: 100%; max-width: 480px; gap: 13px; }
  .home__foot { grid-area: foot; margin: 20px 0 0; text-align: center; font-size: .82rem; }
  .bigbtn { padding: 17px 20px; border-radius: var(--r-lg); }
  .bigbtn__icon { width: 52px; height: 52px; font-size: 2rem; border-radius: 15px; }
  .bigbtn__text b { font-size: 1.12rem; }
  .bigbtn__text small { font-size: .82rem; }
  .home__row .bigbtn { padding: 15px 16px; }
  .home__row .bigbtn__icon { width: 46px; height: 46px; font-size: 1.6rem; }
  .home__row .bigbtn__text b { font-size: 1.02rem; }
  .account-chip { font-size: .76rem; padding: 6px 14px; max-width: 240px; }
  .ai-setup__label { font-size: .92rem; }
  .ai-setup__select { font-size: .92rem; }

  /* ---------- LOGIN ---------- */
  .login__body { padding: 10px 20px 46px; }
  .login__lizard { font-size: 3.8rem; margin-bottom: 10px; }
  .auth-card { max-width: 410px; padding: 30px 28px 24px; }
  .auth-card h2 { font-size: 1.55rem; }
  .auth-input { font-size: 1rem; padding: 13px 14px; }
  .auth-submit { padding: 14px; font-size: 1rem; }

  /* ---------- GAME: felt table, uses the width ---------- */
  .zone { padding: 14px 40px; }
  .opps { max-width: 1040px; margin: 0 auto; justify-content: center; flex-wrap: wrap; }
  .opp__name { font-size: .9rem; }
  .opp__meta { font-size: .74rem; }
  .ccard--opp { width: 48px; height: 73px; }
  .opp__fan { height: 30px; }
  .opp__fan .minicard { width: 21px; height: 30px; margin-left: -13px; }

  .piles { margin: auto 0; gap: 46px; padding: 8px 0 10px; }
  .pile { gap: 8px; }
  .pile__label { font-size: .72rem; }
  .pile__count { font-size: .68rem; }

  .status { font-size: 1.04rem; min-height: 44px; padding: 11px 14px; }
  .actionbar { min-height: 52px; padding: 6px 12px; }
  .actionbar .btn { font-size: .95rem; padding: 12px 24px; }

  .zone--me { padding-bottom: 26px; }
  .zone__row--me { gap: 20px; }
  .color-label__cap { font-size: .66rem; }
  .color-label b { font-size: 1.15rem; }
  .hand { min-height: 168px; padding: 18px 8px 6px; }
  .hand .pcard { margin-left: -28px; }
  .ccard--me { width: var(--card-w); height: var(--card-h); }

  /* ---------- FRIENDS / HOW TO ---------- */
  .friends-body { max-width: 640px; margin: 0 auto; width: 100%; padding: 8px 20px 30px; }
  .fr-name { font-size: .95rem; }
  .howto-body { max-width: 780px; margin: 0 auto; width: 100%; padding: 6px 24px 34px; }
  .howto-hero__title { font-size: 1.7rem; }
  .howto-hero__sub { font-size: .95rem; }
  .rule { grid-template-columns: 40px 1fr; padding: 20px 22px; gap: 16px; }
  .rule__main h4 { font-size: 1.15rem; }
  .rule__main p { font-size: .9rem; }
  .cardback-mini { width: 48px; height: 73px; }
  .pcard-mini { width: 56px; height: 85px; }
  .ccard--guide { width: 52px; height: 79px; }

  /* ---------- overlays sized up ---------- */
  .panel { max-width: 470px; padding: 28px 30px 24px; }
  .panel h2 { font-size: 1.65rem; }
  .panel__sub { font-size: .92rem; }
  .score-table { font-size: .9rem; }
  .lb-panel { max-width: 580px; }
  .lb-title { font-size: 1.65rem; }
  .lb-list { max-height: 54vh; }
  .lb-row { font-size: .9rem; padding: 10px 12px; grid-template-columns: 38px 1fr 52px 56px 52px; }
  .mp-panel h2 { font-size: 1.5rem; }
  .mp-spinner { font-size: 3.4rem; }
}

/* Short desktops (1366x768 / 1280x720): trim vertical sizing to fit. */
@media (min-width: 900px) and (max-height: 800px) {
  :root { --card-w: 78px; --card-h: 118px; }
  .home { padding: 18px 60px 22px; }
  .home__lizard { font-size: 5.6rem; }
  .home__logo { font-size: 3.9rem; }
  .home__tag { font-size: 1.05rem; margin-top: 12px; }
  .zone { padding: 10px 40px; }
  .piles { gap: 40px; padding: 4px 0 6px; }
  .status { min-height: 38px; padding: 8px 14px; }
  .actionbar { min-height: 44px; }
  .zone--me { padding-bottom: 14px; }
  .hand { min-height: 146px; padding: 12px 8px 4px; }
  .ccard--opp { width: 42px; height: 64px; }
}

/* Very wide screens: hold the table at a comfortable width. */
@media (min-width: 1500px) { .app { max-width: 1180px; } }

/* ============================ reduced motion ============================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .home__lizard, .mp-spinner { animation: none; }
}
