/*
Filename: style.css
Last Edit Date: 2026-12-03 EST
Purpose: The look of Tail Sweep: a cozy night-blue page, an orange cat at the top with a long tail that sweeps over the table, and a grid of cards that flip over.
*/

:root {
  --bg: #1d2747; --panel: #26325c; --ink: #f4f1ea; --muted: #a9b4d6; --line: #3a4a82; --accent: #ffcf6b;
  --card-back: #5b6bd6; --card-back2: #3f4db0; --card-front: #fffdf6; --sweep: 700ms; --tail: min(230px, 44vw);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; background: radial-gradient(ellipse at 50% 0, #2f3d78, var(--bg) 70%); color: var(--ink); font: 16px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-user-select: none; user-select: none; }
.hidden { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: rgba(10, 14, 30, .55); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 1.35rem; color: var(--accent); letter-spacing: .02em; }
.top-right { display: flex; gap: 8px; }
.btn { border: 1px solid var(--accent); background: transparent; color: var(--accent); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; transition: background .15s ease, transform .1s ease; }
.btn:hover:not(:disabled) { background: rgba(255, 207, 107, .15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn.big { background: var(--accent); color: #2a1f05; padding: 12px 22px; font-size: 1.05rem; box-shadow: 0 3px 10px rgba(255, 207, 107, .3); }
.btn.big:hover:not(:disabled) { background: #ffdc91; }
.btn.big small { display: block; font-weight: 400; font-size: .78rem; opacity: .8; margin-top: 2px; }

.game { max-width: 640px; margin: 0 auto; padding: 12px 12px 30px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats > div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 4px; text-align: center; }
.stats .label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stats b { font-size: 1.3rem; }

/* The stage: the cat sits at the top, the tail hangs from its back and swings across the table. */
.stage { position: relative; padding-top: 128px; margin-top: 4px; }
.cat { position: absolute; top: 0; left: 50%; width: 160px; transform: translateX(-50%); z-index: 4; pointer-events: none; }
.cat-svg { width: 100%; height: auto; display: block; }
.tail { position: absolute; top: 98px; left: 50%; height: var(--tail); width: calc(var(--tail) * 0.1667); margin-left: calc(var(--tail) * -0.0833); transform-origin: 50% 3%; transform: rotate(78deg);
  transition: transform var(--sweep) cubic-bezier(.45, .05, .55, .95); z-index: 5; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
.tail svg { width: 100%; height: 100%; display: block; }
.tail.right { transform: rotate(-78deg); }
.tail.rest { animation: sway 2.4s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(78deg); } 50% { transform: rotate(72deg); } }

.table { display: grid; grid-template-columns: repeat(4, 70px); justify-content: center; gap: 8px; perspective: 900px; }          /* the page sets the columns and the card size so the whole table fits on the screen */
.card { position: relative; aspect-ratio: 5 / 6; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; transition: opacity .45s ease, transform .45s ease; }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .35s ease; }
.card.up .inner { transform: rotateY(180deg); }
.card .back, .card .front { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 2px 5px rgba(0, 0, 0, .35); }
.card .back { background: linear-gradient(150deg, var(--card-back), var(--card-back2)); border: 2px solid #8e9bf0; font-size: calc(var(--card-w, 70px) * .34); opacity: .95; }
.card .front { background: var(--card-front); color: #1b2540; border: 2px solid #d9d2bd; transform: rotateY(180deg); font-size: calc(var(--card-w, 70px) * .5); font-weight: 800; }
.card.peeked .front { box-shadow: 0 0 0 3px var(--accent), 0 0 14px rgba(255, 207, 107, .75); }
.card.sel .front { box-shadow: 0 0 0 3px #7be0ff, 0 0 12px rgba(123, 224, 255, .7); }
.card.gone { opacity: 0; transform: translateX(-60px) rotate(-14deg) scale(.7); pointer-events: none; }
.card.gone .inner { transition: none; }
.table.locked .card { cursor: default; }

.phase { margin-top: 14px; min-height: 1.6rem; text-align: center; font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.bar { height: 10px; margin-top: 6px; background: rgba(255, 255, 255, .12); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #7be0ff, #5b6bd6); }

.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 12, 28, .86); }
.overlay-card { max-width: 420px; width: 100%; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.overlay-card h2 { margin: 0 0 8px; color: var(--accent); font-size: 1.6rem; }
.overlay-card p { margin: 0 0 16px; color: var(--ink); }
.mode-buttons { display: grid; gap: 10px; }

@media (max-width: 560px) {
  .stage { padding-top: 124px; }
  .stats b { font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) { .tail.rest { animation: none; } .card .inner { transition-duration: .01s; } }

/* Numbers: choosing what the pairs add up to, and the reminder under the numbers. */
.total-picker { display: grid; gap: 10px; }
.total-ask { margin: 0; font-weight: 700; font-size: 1.1rem; }
.total-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.total-quick .btn.big { padding: 12px 0; font-size: 1.3rem; }
.total-own { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.total-own label { color: var(--muted); font-size: .9rem; }
.field { width: 80px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #141c36; color: var(--ink); font: inherit; font-size: 1.1rem; text-align: center; -webkit-user-select: text; user-select: text; }
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.total-error { margin: 0; min-height: 1.2rem; color: #ff9b9b; font-weight: 600; }
.goal { margin: 6px 0 0; text-align: center; font-size: 1.05rem; color: var(--accent); }
.card .front.wide { font-size: calc(var(--card-w, 70px) * .38); }

/* Stars for a cleared table, the little stars on the start buttons, and the "next step" suggestion. */
.stars { font-size: 2.6rem; line-height: 1; letter-spacing: .12em; color: var(--accent); margin: 0 0 8px; text-shadow: 0 0 12px rgba(255, 207, 107, .55); }
.stars .off { opacity: .22; text-shadow: none; }
.stars .pop { display: inline-block; animation: pop .5s ease-out both; }
.stars .pop:nth-child(2) { animation-delay: .2s; }
.stars .pop:nth-child(3) { animation-delay: .4s; }
@keyframes pop { 0% { transform: scale(.2) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.3) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.stars-mini { display: block; min-height: 1em; margin-top: 2px; font-size: .85rem; letter-spacing: .12em; color: #7a4e00; }
.stars-mini .off { opacity: .3; }
.step-text { margin: 12px 0 8px; font-weight: 700; color: var(--accent); }
#next-step { margin-bottom: 8px; width: 100%; }
#again { width: 100%; }
@media (prefers-reduced-motion: reduce) { .stars .pop { animation: none; } }
