/* Card Recall — styles. A bright menu, a sunny tablecloth, cards that flip. */
:root {
  --bg: #eef3fb;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #5d6678;
  --line: #d6dce8;
  --blue: #2f6fe0;
  --blue-dark: #1d4fb0;
  --go: #f07c00;
  --go-dark: #c76400;
  --right: #2fa35a;
  --half: #e8a317;
  --wrong: #d0402e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button {
  font: inherit; font-weight: 700; border: 2px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 8px 16px; cursor: pointer; touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: default; }
button.go { background: var(--go); border-color: var(--go-dark); color: #fff; font-size: 18px; padding: 10px 22px; }
button.go:not(:disabled):hover { background: var(--go-dark); }
button.secondary { background: #fff; }
button.danger { color: var(--wrong); border-color: #f0c4be; }
button.icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 20px; }
button.plain { border: none; background: none; }
.small { color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; background: var(--blue); color: #fff;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 6px; }
.brand-cards { font-size: 30px; line-height: 1; }
.top-right { display: flex; gap: 8px; align-items: center; }
.player-chip { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .5); padding: 6px 14px; }
.topbar button.icon { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .5); }

.update-note {
  display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; background: #fff4d6;
  border-bottom: 1px solid #f0d58a; font-weight: 600;
}

/* ---------- home ---------- */
.home { max-width: 860px; width: 100%; margin: 0 auto; padding: 14px 14px 24px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.home h2 { margin: 0 0 10px; font-size: 18px; color: var(--blue-dark); }
.players { display: flex; flex-wrap: wrap; gap: 10px; }
.player {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 8px; border-radius: 30px; border: 3px solid var(--line);
}
.player-emoji { font-size: 30px; line-height: 1; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #f2f5fa; }
.player.on { border-color: var(--pc, var(--blue)); background: color-mix(in srgb, var(--pc, var(--blue)) 10%, #fff); }
.player.add { color: var(--muted); border-style: dashed; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-width: 3px; }
.mode-name { font-size: 18px; }
.mode-desc { font-weight: 500; color: var(--muted); font-size: 14px; }
.mode.on { border-color: var(--blue); background: #eaf1fe; }
.levels { display: flex; flex-wrap: wrap; gap: 10px; }
.level { display: flex; flex-direction: column; align-items: center; min-width: 84px; padding: 8px 12px; border-width: 3px; }
.level-n { font-size: 30px; line-height: 1.1; }
.level-word { font-size: 13px; color: var(--muted); font-weight: 600; }
.level-stars { color: #f2b705; letter-spacing: 1px; font-size: 16px; }
.level.on { border-color: var(--go); background: #fff3e6; }
.home-go { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.home-go .go { font-size: 22px; padding: 12px 36px; }

/* ---------- a round ---------- */
.play { flex: 1; display: grid; grid-template-rows: auto 1fr auto auto; gap: 8px; padding: 8px 12px 12px; min-height: 0; }
.play-bar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.prompt { flex: 1; font-size: 20px; font-weight: 800; color: var(--blue-dark); }
.timer { display: flex; align-items: center; gap: 8px; width: min(40%, 300px); }
.timer-track { flex: 1; height: 12px; background: #dfe5ef; border-radius: 6px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--right); border-radius: 6px; transition: width .1s linear; }
.timer-fill.low { background: var(--wrong); }
.timer-text { font-weight: 800; min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

.table {
  position: relative; min-height: 230px; border-radius: 22px; overflow: hidden;
  border: 5px solid var(--cloth-edge); background-color: var(--cloth);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .08);
}
/* Tablecloths: bright, well-lit patterns (picked in Settings). */
.table[data-cloth="sunny"] {
  --cloth: #fff6cf; --cloth-edge: #f5d76e;
  background-image:
    radial-gradient(circle, #ffffff 0 7px, transparent 8px),
    radial-gradient(circle, #ffe79a 0 5px, transparent 6px);
  background-size: 56px 56px, 56px 56px; background-position: 0 0, 28px 28px;
}
.table[data-cloth="picnic"] {
  --cloth: #ffffff; --cloth-edge: #9fd8b4;
  background-image:
    linear-gradient(90deg, rgba(110, 200, 145, .28) 50%, transparent 50%),
    linear-gradient(rgba(110, 200, 145, .28) 50%, transparent 50%);
  background-size: 48px 48px;
}
.table[data-cloth="sky"] {
  --cloth: #dff0ff; --cloth-edge: #9cc9f2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='120'%3E%3Cg fill='%23ffffff' opacity='.9'%3E%3Cellipse cx='30' cy='30' rx='18' ry='9'/%3E%3Cellipse cx='42' cy='24' rx='12' ry='10'/%3E%3Cellipse cx='112' cy='88' rx='20' ry='9'/%3E%3Cellipse cx='124' cy='81' rx='13' ry='11'/%3E%3C/g%3E%3Cg fill='%23ffd34d'%3E%3Cpath d='M120 22l3 6 6 1-4.5 4 1 6-5.5-3-5.5 3 1-6-4.5-4 6-1z'/%3E%3Cpath d='M40 92l2 4 4 .6-3 3 .7 4-3.7-2-3.7 2 .7-4-3-3 4-.6z'/%3E%3C/g%3E%3C/svg%3E");
}
.table[data-cloth="confetti"] {
  --cloth: #fdf8ff; --cloth-edge: #d9b8f0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Ccircle cx='14' cy='18' r='4' fill='%23ff8fa3'/%3E%3Ccircle cx='70' cy='10' r='3' fill='%2368c3ff'/%3E%3Ccircle cx='100' cy='52' r='4' fill='%23ffd34d'/%3E%3Ccircle cx='40' cy='64' r='3' fill='%237ed99b'/%3E%3Ccircle cx='86' cy='100' r='4' fill='%23b58cff'/%3E%3Ccircle cx='20' cy='104' r='3' fill='%23ffb35c'/%3E%3Crect x='54' y='36' width='9' height='4' rx='2' fill='%2368c3ff' transform='rotate(30 58 38)'/%3E%3Crect x='104' y='14' width='9' height='4' rx='2' fill='%23ff8fa3' transform='rotate(-25 108 16)'/%3E%3Crect x='56' y='86' width='9' height='4' rx='2' fill='%23ffd34d' transform='rotate(60 60 88)'/%3E%3C/svg%3E");
}
.deck { position: absolute; left: 14px; top: 14px; width: var(--cw, 70px); height: calc(var(--cw, 70px) * 1.4); }
.deck { transition: opacity .4s, transform .4s; }
.deck.away { opacity: 0; transform: translate(-30px, -30px); }
.deck::before, .deck::after {
  content: ""; position: absolute; inset: 0; border-radius: 8%;
  background: #2f6fe0; border: 3px solid #fff; box-shadow: 2px 3px 0 #1d4fb0, 4px 6px 0 #fff, 5px 8px 6px rgba(0, 0, 0, .3);
}
.deck::after { background: repeating-linear-gradient(45deg, #2f6fe0 0 6px, #3d7cf0 6px 12px); transform: translate(-2px, -2px); }

.hand { position: absolute; inset: 0; --cw: 110px; }
.card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: calc(var(--cw) * 1.4);
  transform: translate(20px, 20px) scale(.6); opacity: 0;
  transition: transform .45s cubic-bezier(.2, .8, .3, 1.1), opacity .2s, filter .2s;
  perspective: 900px; cursor: default;
}
.card.dealt { transform: translate(var(--x), calc(var(--y) - var(--up, 0px))) rotate(var(--r)); opacity: 1; }
.card-inner {
  position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .42s ease;
  transform: rotateY(180deg);
}
.card.up .card-inner { transform: rotateY(0deg); }
.card-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 8%; }
.card-face.back { transform: rotateY(180deg); }
.card-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(1px 3px 3px rgba(0, 0, 0, .35)); }
.play .card { cursor: pointer; }
.card.active { --up: 16px; filter: drop-shadow(0 0 10px #ffd84d) drop-shadow(0 0 4px #ffd84d); z-index: 50 !important; }
.card.guess .front { outline: 3px dashed rgba(255, 255, 255, .8); outline-offset: 2px; }
.card.checked.right .front { box-shadow: 0 0 0 4px var(--right); }
.card.checked.half .front { box-shadow: 0 0 0 4px var(--half); }
.card.checked.wrong .front { box-shadow: 0 0 0 4px var(--wrong); }
.badge {
  display: none; position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%);
  background: #fff; border-radius: 14px; padding: 2px 9px; font-weight: 800; white-space: nowrap;
  font-size: 15px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); z-index: 2;
}
.card.checked .badge { display: block; animation: pop .3s ease-out; }
.card.checked.right .badge { background: var(--right); color: #fff; font-size: 18px; }
.card.checked.half .badge { border: 2px solid var(--half); }
.card.checked.wrong .badge { border: 2px solid var(--wrong); }
.badge.red-suit { color: #d0202e; }
.badge .you { color: var(--muted); font-weight: 600; font-size: 12px; }
@keyframes pop { from { transform: translateX(-50%) scale(.4); } to { transform: translateX(-50%) scale(1); } }

.result {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 100;
  background: rgba(255, 255, 255, .95); border-radius: 18px; padding: 8px 22px 10px; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35); min-width: min(90%, 340px);
}
.result-stars { font-size: 38px; line-height: 1.1; letter-spacing: 4px; }
.star { color: #d9dde5; display: inline-block; }
.star.won { color: #f2b705; animation: star .5s both; animation-delay: var(--d); }
@keyframes star { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.result-text { font-size: 19px; font-weight: 800; }
.result-detail { color: var(--muted); font-weight: 600; font-size: 14px; }

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.actions:empty { display: none; }

/* the wheels */
.picker {
  display: flex; gap: 18px; align-items: center; justify-content: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 8px 14px;
}
.wheels { display: flex; gap: 10px; }
.wheel-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wheel-step { padding: 0; width: 64px; height: 30px; font-size: 14px; border-radius: 10px; color: var(--muted); }
.wheel {
  --ih: 50px; position: relative; height: calc(var(--ih) * 3); width: 84px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(180deg, #cfd5df, #fff 30%, #fff 70%, #cfd5df); border: 2px solid #b9c0cc; outline: none;
}
.wheel:focus-visible { border-color: var(--blue); }
.wheel-list {
  height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; padding: var(--ih) 0; scrollbar-width: none;
  overscroll-behavior: contain;
}
.wheel-list::-webkit-scrollbar { display: none; }
.wheel-item {
  height: var(--ih); display: grid; place-items: center; scroll-snap-align: center; font-size: 30px; font-weight: 800;
  font-family: Georgia, "Times New Roman", serif; color: #9aa2b1; cursor: pointer; user-select: none;
}
.wheel-item.on { color: var(--text); font-size: 34px; }
.wheel-band {
  position: absolute; left: 0; right: 0; top: var(--ih); height: var(--ih); pointer-events: none;
  border-top: 2px solid rgba(47, 111, 224, .5); border-bottom: 2px solid rgba(47, 111, 224, .5); background: rgba(47, 111, 224, .07);
}
.pick-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pick-card { width: 92px; }
.pick-card .card-svg { filter: drop-shadow(1px 3px 4px rgba(0, 0, 0, .3)); }

/* Wide but short screens (a tablet held sideways): the wheels sit beside the table. */
@media (min-aspect-ratio: 4/3) and (max-height: 820px) {
  .play { grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; }
  .play-bar { grid-column: 1 / -1; }
  .table { grid-column: 1; grid-row: 2; }
  .actions { grid-column: 1; grid-row: 3; }
  .picker { grid-column: 2; grid-row: 2 / 4; flex-direction: column; gap: 10px; }
  .wheel { --ih: 54px; }
}

/* ---------- dialogs ---------- */
.dialog { max-width: 460px; width: calc(100% - 28px); border: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.dialog.wide { max-width: 760px; }
.dialog::backdrop { background: rgba(10, 20, 40, .45); }
.dialog h2 { margin: 0 0 12px; color: var(--blue-dark); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field input[type=text], .field select { font: inherit; font-weight: 500; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; }
.field input[type=checkbox] { width: 22px; height: 22px; }
.field-label { font-weight: 700; margin-bottom: 6px; }
.emoji-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.emoji-pick button { font-size: 26px; padding: 4px 0; border-radius: 10px; }
.emoji-pick button.on { border-color: var(--blue); background: #eaf1fe; }
.dialog-buttons { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }
.help li { margin-bottom: 8px; line-height: 1.45; }
.scores { border-collapse: collapse; width: 100%; font-size: 14px; }
.scores th, .scores td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.scores .who { text-align: left; white-space: nowrap; font-weight: 700; }
.mini-stars { color: #f2b705; font-size: 12px; letter-spacing: 0; }
#scores { overflow-x: auto; }

/* Touch screens: bigger targets. */
html.touch .wheel-step { height: 36px; width: 72px; }
html.touch .wheel { width: 92px; }

/* Phones and narrow screens */
@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .brand { font-size: 18px; }
  .prompt { font-size: 16px; }
  .picker { gap: 10px; }
  .wheel { width: 70px; }
  .pick-card { width: 74px; }
}
