:root {
  /* Look inspired by "XTreme 10": deep blue gloss, white cards with coloured corners, black pill bars. */
  --bg: #0a2a6b;
  --bg-2: #1f6fe0;
  --panel: rgba(4, 18, 52, .45);
  --text: #ffffff;
  --muted: #b9cdf3;
  --accent: #ffd21f;
  --danger: #ff6b6b;
  --red: #e5262b;
  --blue: #1f56d8;
  --green: #22a33b;
  --yellow: #f5b800;
  --ring: conic-gradient(#e5262b, #f5b800, #ffe14d, #22a33b, #1fb5e0, #1f56d8, #8b2fc9, #e5262b);
  --radius: 12px;
  --gutter: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior-y: none;
}
/* Gradient on its own fixed layer: iOS Safari ignores background-attachment: fixed. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(120% 70% at 50% -10%, var(--bg-2), var(--bg) 70%);
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + var(--gutter))
           calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + var(--gutter));
}
h1 { font-size: 1.6rem; margin: 18px 0 4px; text-align: center; letter-spacing: .02em; }
.logo {
  width: 150px; height: 150px; margin: 18px auto 8px; border-radius: 50%; padding: 10px;
  background: var(--ring); box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.logo div {
  width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #fff, #dfe5ee 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #333;
  font-weight: 900; line-height: 1; text-shadow: 0 2px 0 #fff, 0 3px 4px rgba(0,0,0,.25);
}
.logo small { font-size: 1.1rem; letter-spacing: .08em; }
.logo b { font-size: 3.4rem; }
h2 { font-size: 1.05rem; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
label { display: block; font-size: .9rem; color: var(--muted); margin: 0 0 6px; }
input {
  width: 100%; font: inherit; font-size: 18px; /* >= 16px: iOS does not zoom */
  padding: 12px 14px; border-radius: 10px; border: 2px solid transparent;
  background: #fff; color: #111; outline: none; border-radius: 999px;
}
input:focus { border-color: var(--accent); }
input.code { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }
button {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; cursor: pointer;
  min-height: 48px; padding: 10px 18px; background: #0b0b0f; color: #fff;
  border: 2px solid rgba(255,255,255,.85); border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,.3);
}
button.primary { background: var(--accent); color: #1c1300; border-color: #fff; }
button.ghost { background: transparent; color: var(--muted); text-decoration: underline; min-height: 40px; border: 0; box-shadow: none; }
button:disabled { opacity: .45; cursor: default; }
button.block { width: 100%; margin-top: 12px; }
.or { text-align: center; color: var(--muted); margin: 6px 0; }
.bigcode { font-size: 3rem; font-weight: 800; letter-spacing: .25em; text-align: center; margin: 4px 0 8px; padding-left: .25em; }
.players { list-style: none; margin: 0; padding: 0; }
.players li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.players li:last-child { border-bottom: 0; }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.14); color: var(--muted); }
.badge.me { background: var(--accent); color: #1c1300; }
.net {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; text-align: center;
  padding: calc(env(safe-area-inset-top) + 4px) 8px 4px; font-size: .85rem;
  background: #7c2d12; color: #fff;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(env(safe-area-inset-bottom) + 90px); max-width: calc(100% - 32px);
  background: #111; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* ---------- game board (layout after "XTreme 10") ---------- */
.row { display: flex; gap: 10px; margin-top: 12px; }
.row > button { flex: 1; }
button.small { min-height: 34px; padding: 4px 12px; font-size: .8rem; }
button.icon { padding: 4px 10px; font-size: 1.1rem; line-height: 1; }

body.in-game { overflow: hidden; position: fixed; inset: 0; }
/* Light arcs across the blue, like the original's background. */
body.in-game::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(140% 40% at 0% 22%, transparent 60%, rgba(255,255,255,.16) 61%, transparent 64%),
    radial-gradient(150% 45% at 100% 30%, transparent 62%, rgba(255,170,190,.14) 63%, transparent 66%);
}
.board {
  position: fixed; inset: 0; margin: 0 auto; max-width: 560px;
  display: flex; flex-direction: column; gap: 5px; overflow: hidden;
  padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 8px)
           calc(env(safe-area-inset-bottom) + 6px) calc(env(safe-area-inset-left) + 8px);
}
.board::before {
  content: ""; position: absolute; left: 50%; top: 38%; width: min(52vw, 230px); aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--ring); opacity: .18; pointer-events: none;
  -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%); mask: radial-gradient(circle, transparent 60%, #000 61%);
}

/* Other players */
.opps { display: flex; gap: 6px; flex: 0 0 auto; }
.opp {
  flex: 1 1 0; min-width: 0; padding: 5px 4px 4px; text-align: center; border-radius: 12px;
  background: rgba(255,255,255,.17); border: 2px solid transparent;
}
.opp.on { border-color: var(--accent); box-shadow: 0 0 14px rgba(255, 210, 31, .55); }
.opp .nm { font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.opp .st { font-size: .68rem; color: #dbe7ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp .skipped { color: #fca5a5; font-weight: 700; }
.opp { position: relative; }
.opp.skip { border-color: var(--red); background: rgba(229, 38, 43, .35); }
.skipmark {
  position: absolute; top: -6px; right: -4px; width: 28px; height: 28px; border-radius: 50%; font-style: normal;
  background: var(--red); color: #fff; border: 2px solid #fff; font: 900 1.1rem/24px system-ui, sans-serif; text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.skipbar {
  flex: 0 0 auto; text-align: center; font-weight: 800; padding: 6px 10px; border-radius: 10px;
  background: var(--red); border: 2px solid #fff; animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 18px rgba(229, 38, 43, .9); } }
.mini-fan { display: flex; justify-content: center; height: 24px; padding-left: 9px; }
.mini-fan span {
  width: 15px; height: 22px; margin-left: -9px; border-radius: 2px; border: 1px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.4);
  background: linear-gradient(90deg, var(--red) 50%, var(--green) 50%) top / 100% 50% no-repeat,
              linear-gradient(90deg, var(--yellow) 50%, #8b2fc9 50%) bottom / 100% 50% no-repeat;
}

.status {
  flex: 0 0 auto; align-self: center; max-width: 100%; padding: 5px 14px; border-radius: 999px; text-align: center;
  font-weight: 700; font-size: .82rem; background: rgba(0,0,0,.55); border: 1.5px solid rgba(255,255,255,.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status.turn { background: var(--accent); color: #1c1300; border-color: #fff; }
.status.skip { background: var(--red); border-color: #fff; }

/* Laid-down phases */
.tablezone {
  flex: 1 1 auto; min-height: 80px; overflow-y: auto; position: relative; -webkit-overflow-scrolling: touch;
  display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 8px 12px; padding: 4px 0;
}
.empty-table { margin: auto; color: rgba(255,255,255,.45); font-size: .85rem; }
.grp { padding: 4px 6px 2px; border-radius: 10px; border: 2px dashed transparent; }
.fan { display: flex; justify-content: center; }
.grp .card { --w: 40px; }
.grp .card + .card { margin-left: -25px; }
.grp .gl { font-size: .62rem; color: #dbe7ff; text-align: center; margin-top: 1px; }
.ticker { flex: 0 0 auto; font-size: .7rem; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1em; }

/* Parking slots for the own phase, piles on the right */
.mid { position: relative; flex: 0 0 auto; display: flex; gap: 8px; align-items: stretch; }
.slots { flex: 1 1 auto; display: flex; gap: 6px; min-width: 0; }
.slot {
  flex: 1 1 0; min-width: 0; min-height: 92px; padding: 6px 3px 3px; border-radius: 10px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: rgba(255,255,255,.1); border: 2px dashed rgba(255,255,255,.35);
}
.slot .fan { min-height: 64px; align-items: center; overflow: hidden; }
.slot .card { --w: 42px; }
.slot .card + .card { margin-left: -28px; }
.slot .sl { font-size: .68rem; text-align: center; color: #dbe7ff; line-height: 1.15; }
.slot.ok { border: 2px solid #4ade80; background: rgba(74, 222, 128, .16); }
.slot.ok .sl { color: #bbf7d0; font-weight: 800; }
.slot.done { justify-content: center; align-items: center; border-style: solid; }
.piles { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
.pile { border-radius: 10px; padding: 2px; border: 2px dashed transparent; }
.pile .card { --w: 56px; }
.laybar {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 4; min-height: 40px; padding: 4px 16px;
  display: flex; justify-content: space-between; align-items: center; color: #fff; font-weight: 800;
  background: linear-gradient(#5ee38f, #15803d); border: 2px solid #fff; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); animation: pop .25s ease-out;
}
.laybar span { color: #bbf7d0; font-size: 1.3rem; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* Own hand: one overlapping row that spreads out when there is room */
.hand {
  --hw: min(68px, 18vw); --room: calc(min(100vw, 560px) - 16px);
  flex: 0 0 auto; display: flex; justify-content: center; align-items: flex-end;
  min-height: calc(var(--hw) * 1.45 + 18px); padding-top: 14px; border-radius: 12px; border: 2px dashed transparent;
}
.hand .card { --w: var(--hw); margin-left: calc(-1 * max(-4px, var(--hw) - (var(--room) - var(--hw)) / (var(--n) - 1))); }
.hand .card:first-child { margin-left: 0; }
.board.my-turn .hand { background: radial-gradient(60% 80% at 50% 100%, rgba(255, 210, 31, .22), transparent 70%); }
.tools { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; font-size: .78rem; color: var(--muted); }
.tools span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools b { color: var(--text); }

/* Drag and drop */
[data-drag] { touch-action: none; cursor: grab; }
body.dragging, body.dragging * { cursor: grabbing !important; }
.can { border-color: rgba(255, 210, 31, .9) !important; border-style: dashed !important; background-color: rgba(255, 210, 31, .1); }
.opp.can { border-width: 2px; }
.over { border-style: solid !important; background-color: rgba(255, 210, 31, .32) !important; }
.lifted { opacity: .25; }
.card.ghost { position: fixed; left: 0; top: 0; z-index: 60; margin: 0 !important; pointer-events: none; box-shadow: 0 14px 28px rgba(0,0,0,.55); }
.card.sel { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--accent), 0 8px 16px rgba(0,0,0,.5); }
.card.glow { box-shadow: 0 0 0 3px #fff, 0 0 18px 5px rgba(255,255,255,.65); animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px #fff, 0 0 26px 9px rgba(255, 225, 120, .8); } }

/* Cards: white, coloured triangles top right and bottom left, numbers in all corners, rainbow ring in the middle. */
.card {
  --w: 56px; --c: #888;
  position: relative; flex: 0 0 auto; width: var(--w); height: calc(var(--w) * 1.45); overflow: hidden;
  border-radius: calc(var(--w) * .1); background: #fff; color: var(--c); font-size: calc(var(--w) * .3);
  box-shadow: 0 1px 4px rgba(0,0,0,.45), inset 0 0 0 1px rgba(0,0,0,.12);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .12s ease;
}
.card::before, .card::after { content: ""; position: absolute; inset: 0; background: var(--c); }
.card::before { clip-path: polygon(42% 0, 100% 0, 100% 58%); }
.card::after { clip-path: polygon(0 42%, 58% 100%, 0 100%); }
.card .c { position: absolute; z-index: 1; font-style: normal; font-weight: 900; line-height: 1; font-size: .9em; }
.card .tl { top: 5%; left: 8%; }
.card .tr { top: 5%; right: 8%; color: #fff; }
.card .bl { bottom: 5%; left: 8%; color: #fff; }
.card .br { bottom: 5%; right: 8%; }
.card b {
  position: absolute; z-index: 1; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 2.1em; height: 2.1em; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, #fff 60%, transparent 62%), var(--ring);
  font-size: 1.05em; font-weight: 900; line-height: 1; box-shadow: 0 0 0 1px rgba(255,255,255,.8);
}
.card.red { --c: var(--red); }
.card.blue { --c: var(--blue); }
.card.green { --c: var(--green); }
.card.yellow { --c: var(--yellow); }
.card.wild { --c: #1f56d8; }
.card.skip { --c: #14141a; }
.card.back {
  background: linear-gradient(90deg, var(--red) 50%, var(--green) 50%) top / 100% 50% no-repeat,
              linear-gradient(90deg, var(--yellow) 50%, #8b2fc9 50%) bottom / 100% 50% no-repeat;
  box-shadow: 0 1px 4px rgba(0,0,0,.45), inset 0 0 0 3px #fff;
}
.card.back::before, .card.back::after { display: none; }
.card.back b { color: #333; }
.card.back em {
  position: absolute; z-index: 2; right: 4%; bottom: 3%; font-style: normal; font-weight: 800; font-size: .75em;
  color: #fff; background: rgba(0,0,0,.6); border-radius: 999px; padding: 1px 5px;
}
.card.empty { background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 2px rgba(255,255,255,.3); }
.card.empty::before, .card.empty::after { display: none; }

/* Results and small dialogs */
.sheet {
  position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .panel {
  width: 100%; max-width: 560px; margin: 0; border-radius: 18px 18px 0 0; background: #0a2a6b;
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px); max-height: 90dvh; overflow-y: auto;
}
.results h2 { color: var(--text); font-size: 1.3rem; text-align: center; margin-bottom: 2px; }
.results table { width: 100%; border-collapse: collapse; font-size: .95rem; margin-top: 8px; }
.results th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 4px 4px 6px; }
.results td { padding: 8px 4px; border-top: 1px solid rgba(255,255,255,.1); }
.results .num { text-align: right; }
.results tr.me td { color: var(--accent); }
.results .up { color: #4ade80; font-size: .8em; }
.sheet.final { background: var(--bg); align-items: center; }
.sheet.final .panel { border-radius: 18px; background: transparent; }
.info h2 { text-align: left; font-size: 1.05rem; margin: 10px 0 4px; }
.phases { list-style: none; margin: 0; padding: 0; }
.phases li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 4px; border-top: 1px solid rgba(255,255,255,.1); font-size: .92rem; }
.phases .n { width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.15); text-align: center; line-height: 24px; font-weight: 800; font-size: .8rem; }
.phases .t { flex: 1; min-width: 50%; }
.phases li.done { color: var(--muted); }
.phases li.done .n { background: #22a33b; }
.phases li.cur { background: rgba(255, 210, 31, .15); border-radius: 8px; }
.phases li.cur .n { background: var(--accent); color: #1c1300; }
.phases .who { font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: rgba(255,255,255,.18); white-space: nowrap; }
.phases .who.me { background: var(--accent); color: #1c1300; font-weight: 700; }
.trophy { font-size: 3rem; text-align: center; line-height: 1; margin: 4px 0 6px; }
.toast { pointer-events: none; }
body.in-game .toast { bottom: auto; top: calc(env(safe-area-inset-top) + 92px); text-align: center; }
.players .remove { margin-left: auto; min-height: 32px; padding: 2px 12px; background: transparent; color: var(--muted); border-color: rgba(255,255,255,.4); box-shadow: none; }
/* Overlapping hand: like the original, only the left strip of each card counts; the last card shows everything. */
.hand .card:not(:last-child) .tr, .hand .card:not(:last-child) .br, .hand .card:not(:last-child) b { visibility: hidden; }
.hand .card:not(:last-child)::before { clip-path: polygon(42% 0, 100% 0, 100% 58%); }
/* A new card on the discard pile drops in, so the change is noticed. */
.card.fresh { animation: drop-in .45s ease-out; }
.card.fresh.glow { animation: drop-in .45s ease-out, glow 1.4s ease-in-out .45s infinite; }
@keyframes drop-in { from { transform: translateY(-40px) scale(1.25) rotate(-8deg); opacity: .2; } }
