/* Flip7 Scoreboard — "retro-playful" teal/coral/gold design system.
   Adapted from flip7-card-game-DESIGN.md (rpx → px, ÷2). */

:root {
  /* ---- palette ---- */
  --teal: #2BA8A2;
  --teal-light: #3CC4BD;
  --teal-dark: #1E8C86;
  --teal-bg: #E8F6F5;

  --gold: #FFD23F;
  --gold-light: #FFE47A;
  --gold-dark: #E6B800;

  --coral: #EF6C4A;
  --coral-light: #FF8A6A;
  --coral-dark: #D45233;

  --cream: #FFF8E7;
  --sky: #5DADE2;

  --surface: #EFF8F7;   /* page bg */
  --card: #FFFFFF;      /* card bg */

  --success: #27AE60;
  --error: #E74C3C;

  /* text / ink */
  --text: #1E3A38;
  --muted: #6B8B88;
  --ink: #233038;       /* retro outline / borders on cream */

  /* ---- radius (rpx/2) ---- */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-round: 999px;

  /* ---- spacing ---- */
  --xs: 4px;
  --sm: 8px;
  --md: 12px;
  --lg: 16px;
  --xl: 24px;

  /* ---- elevation: colored glow system ---- */
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,.12);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.16);
  --shadow-card: 0 2px 10px rgba(43,168,162,.10);
  --shadow-coral-glow: 0 2px 10px rgba(239,108,74,.35);
  --shadow-teal-glow: 0 2px 10px rgba(43,168,162,.30);
  --shadow-accent-glow: 0 2px 10px rgba(255,210,63,.40);
  --shadow-sky-glow: 0 2px 8px rgba(93,173,226,.30);
  --shadow-focus: 0 0 0 4px rgba(43,168,162,.15);

  --bounce: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(900px 500px at 85% -8%, var(--teal-bg) 0%, var(--surface) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

/* ---------- topbar / wordmark ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--md);
  padding: 14px 24px;
  border-bottom: 3px dashed rgba(43,168,162,.30);
  background: rgba(255, 248, 231, .7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}
/* compact FLIP7 wordmark in the bar */
.logo {
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  padding: 4px 12px;
  transform: skewX(-6deg) rotate(-2deg);
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--bounce);
}
.logo:hover { transform: skewX(-6deg) rotate(-2deg) scale(1.04); }
.logo .lf {
  transform: skewX(6deg);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--teal-dark);
}
.logo .l7 {
  transform: skewX(6deg) rotate(5deg);
  font-weight: 800;
  font-size: 30px;
  margin-left: 4px;
  color: var(--gold);
  text-shadow: 1px 1px 0 var(--ink), 2px 2px 0 var(--ink);
}
.tagline { color: var(--teal-dark); font-size: 14px; font-weight: 600; letter-spacing: .5px; }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 90px;
}

h2 { margin: 0 0 16px; font-size: 24px; font-weight: 800; letter-spacing: .5px; color: var(--teal-dark); }
h3 {
  margin: 0 0 12px; font-size: 18px; font-weight: 800; color: var(--teal-dark);
  display: inline-flex; align-items: center; gap: 8px;
  padding-bottom: 8px; border-bottom: 3px dashed rgba(43,168,162,.30);
}

/* ---------- big FLIP7 logo (hero / setup) ---------- */
.flip7-logo {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 0 10px;
  user-select: none;
}
.flip7-logo .fan {
  position: absolute;
  top: 14px; left: 50%;
  width: 0; height: 0;
}
.flip7-logo .fan span {
  position: absolute;
  width: 52px; height: 74px;
  margin-left: -26px; margin-top: -10px;
  border-radius: 8px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-md);
  transform-origin: 50% 90%;
}
.fan .c1 { transform: rotate(-24deg); background: var(--coral); }
.fan .c2 { transform: rotate(-12deg); background: var(--gold); }
.fan .c3 { transform: rotate(0deg);   background: var(--cream); }
.fan .c4 { transform: rotate(12deg);  background: var(--sky); }
.fan .c5 { transform: rotate(24deg);  background: var(--teal); }

.flip7-logo .logo-text {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 26px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: var(--r-md);
  transform: skewX(-6deg) rotate(-3deg);
  box-shadow: var(--shadow-md);
}
.flip7-logo .logo-text .flip {
  transform: skewX(6deg);
  font-size: 44px; font-weight: 800; letter-spacing: 2px;
  color: var(--teal-dark);
  text-shadow: 1px 1px 0 rgba(0,0,0,.12);
}
.flip7-logo .logo-text .seven {
  transform: skewX(6deg) rotate(5deg);
  font-size: 76px; font-weight: 800; line-height: .8;
  color: var(--gold);
  text-shadow: 1px 1px 0 var(--ink), 2px 2px 0 var(--ink), 3px 3px 0 var(--ink);
}
/* folded-ribbon banner */
.flip7-logo .ribbon {
  position: relative;
  z-index: 1;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 7px 26px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--teal-dark);
}
.flip7-logo .ribbon::before,
.flip7-logo .ribbon::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 22px; height: 70%;
  background: var(--gold-dark);
  border: 3px solid var(--ink);
  z-index: -1;
}
.flip7-logo .ribbon::before { left: -16px; transform: skewY(20deg); }
.flip7-logo .ribbon::after  { right: -16px; transform: skewY(-20deg); }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--r-round);
  min-height: 44px;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .3px;
  cursor: pointer;
  color: #fff;
  background: var(--teal);
  box-shadow: var(--shadow-teal-glow);
  transition: transform .12s var(--bounce), filter .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.95); }

.btn-primary {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: var(--ink);
  box-shadow: var(--shadow-accent-glow);
  position: relative;
  overflow: hidden;
}
.btn-primary::before { /* gloss */
  content: "";
  position: absolute; inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.5), transparent);
  pointer-events: none;
}

.btn-ghost {
  background: var(--card);
  color: var(--teal-dark);
  border: 2px solid var(--teal-light);
  box-shadow: var(--shadow-sm);
}
.btn-danger {
  background: var(--card);
  color: var(--coral-dark);
  border: 2px solid var(--coral-light);
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover { background: var(--coral); color: #fff; border-color: var(--coral); }

.btn-sm { min-height: 0; padding: 7px 14px; font-size: 13px; }
.btn-icon { min-height: 0; padding: 7px 11px; line-height: 1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- inputs (cream surfaces) ---------- */
input[type="text"], input[type="number"] {
  background: var(--cream);
  border: 2px solid rgba(35,48,56,.18);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 11px 13px;
  font-size: 15px;
  font-weight: 600;
  outline: none;
  width: 100%;
}
input:focus { border-color: var(--teal); box-shadow: var(--shadow-focus); }

/* ---------- Home ---------- */
.hero {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 10px 28px 30px;
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
  text-align: center;
}
.hero h2 { margin-top: 8px; }
.hero p { color: var(--muted); margin: 8px auto 22px; line-height: 1.55; max-width: 520px; font-weight: 500; }

/* place bar */
.place-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border-radius: var(--r-lg);
  border-left: 6px solid var(--gold);
  padding: 12px 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}
.place-bar .place-icon { font-size: 18px; }
.place-bar .place-label { font-weight: 800; color: var(--teal-dark); }
.place-select {
  flex: 1;
  min-width: 140px;
  background: var(--cream);
  border: 2px solid rgba(35,48,56,.18);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}
.place-select:focus { border-color: var(--teal); box-shadow: var(--shadow-focus); }
.place-select:disabled { opacity: .7; cursor: default; }

.game-list { display: grid; gap: 14px; }
.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--r-lg);
  border-left: 6px solid var(--teal-light);
  padding: 16px 18px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform .12s var(--bounce), box-shadow .15s ease;
}
.game-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-teal-glow); }
.game-card .meta { flex: 1; min-width: 0; }
.game-card .name { font-weight: 800; font-size: 18px; color: var(--teal-dark); }
.game-card .sub { color: var(--muted); font-size: 13px; margin-top: 3px; font-weight: 500; }
.pill {
  font-size: 12px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: var(--r-round);
  background: var(--teal-bg);
  color: var(--teal-dark);
  white-space: nowrap;
}
.pill.win { background: var(--gold-light); color: var(--ink); box-shadow: var(--shadow-accent-glow); }

.empty {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  padding: 32px;
  border: 3px dashed rgba(43,168,162,.30);
  border-radius: var(--r-lg);
}

/* ---------- Setup ---------- */
.panel {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; color: var(--teal-dark); font-size: 14px; font-weight: 700; }

.player-rows { display: grid; gap: 10px; margin-bottom: 14px; }
.player-row { display: flex; gap: 10px; align-items: center; }
.player-row .idx {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border-radius: var(--r-round);
  background: linear-gradient(180deg, var(--teal-light), var(--teal));
  color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow-teal-glow);
}

/* ---------- Game / scoreboard ---------- */
.game-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.game-head h2 { margin: 0; }
.target-note {
  color: var(--teal-dark); font-size: 13px; font-weight: 800;
  background: var(--teal-bg); padding: 5px 12px; border-radius: var(--r-round);
}

.banner {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border-radius: var(--r-xl);
  padding: 22px 24px;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow-accent-glow);
  animation: glow-pulse 2s ease-in-out infinite;
}
.banner b { font-weight: 800; }
.banner .crown { display: inline-block; animation: crown-bounce 1.5s infinite; }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-xl);
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 6px;
}
table.score { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 520px; }
table.score th, table.score td {
  padding: 13px 12px;
  text-align: center;
  white-space: nowrap;
}
table.score thead th {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .5px;
  border-bottom: 3px dashed rgba(43,168,162,.28);
  position: sticky;
  top: 0;
  background: var(--card);
}
table.score tbody td { border-bottom: 1px solid rgba(43,168,162,.12); }
table.score .player-name {
  text-align: left;
  font-weight: 800;
  color: var(--teal-dark);
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
}
table.score tbody tr.winner-row td { background: var(--gold-light); }
table.score tbody tr.winner-row .player-name { background: var(--gold-light); }

.cell-input {
  width: 66px;
  text-align: center;
  padding: 9px 6px;
  font-weight: 700;
}
.flip7-tag {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 800;
  color: var(--sky);
}
.total-cell { font-weight: 800; font-size: 20px; color: var(--text); }
.total-cell .medal { margin-left: 4px; }
.total-cell.rank1 { color: var(--gold-dark); }
.total-cell.rank2 { color: var(--muted); }
.total-cell.rank3 { color: var(--coral-dark); }
.total-cell .crown { display: inline-block; animation: crown-bounce 1.5s infinite; }

tfoot td { padding-top: 10px; }

/* big "new scores" button on the scoreboard screen */
.new-scores-bar { display: flex; justify-content: center; margin-top: 24px; }
.btn-big {
  min-height: 64px;
  padding: 18px 48px;
  font-size: 19px;
  letter-spacing: .5px;
  width: 100%;
  max-width: 440px;
}

/* round entry */
.round-entry { margin-top: 18px; }
.entry-grid { display: grid; gap: 12px; margin: 16px 0; }
.entry-player {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border-left: 6px solid var(--teal-light);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-card);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.entry-player .pname { flex: 1; font-weight: 800; color: var(--teal-dark); }
.entry-player input[type="number"] { width: 92px; text-align: center; }

/* Flip7 bonus toggle — sky blue */
.chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800; color: var(--sky); cursor: pointer; user-select: none;
}
.chk input { width: auto; accent-color: var(--sky); }

/* BOOM (bust) button — coral */
.bust-btn { color: var(--coral-dark); border-color: var(--coral-light); }
.bust-btn.active {
  background: var(--coral); color: #fff; border-color: var(--coral);
  box-shadow: var(--shadow-coral-glow);
  animation: boom-pulse 2s infinite;
}
/* entry row in BOOM state */
.entry-player.busted { border-left-color: var(--coral); background: linear-gradient(90deg, rgba(239,108,74,.10), var(--card) 40%); }
/* entry row with Flip7 active */
.entry-player.flipped { border-left-color: var(--sky); background: linear-gradient(90deg, rgba(93,173,226,.10), var(--card) 40%); }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(30,60,58,.45);
  display: grid; place-items: center;
  z-index: 20; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 26px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { color: var(--teal-dark); font-size: 19px; margin-bottom: 10px; border: none; padding: 0; }
.modal p { color: var(--muted); margin: 0 0 22px; line-height: 1.55; font-weight: 500; }
.modal .row { justify-content: flex-end; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--teal-dark); color: #fff;
  padding: 12px 20px; border-radius: var(--r-round);
  box-shadow: var(--shadow-teal-glow);
  z-index: 30; font-size: 14px; font-weight: 700;
  animation: rise .25s var(--bounce);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- confetti ---------- */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 9px; height: 14px;
  opacity: 0;
  animation: confetti-fall linear infinite;
}

/* ---------- keyframes ---------- */
@keyframes glow-pulse {
  0%, 100% { box-shadow: var(--shadow-accent-glow); }
  50% { box-shadow: 0 4px 22px rgba(255,210,63,.65); }
}
@keyframes crown-bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-4px) rotate(-8deg); }
  50% { transform: translateY(-2px) rotate(0); }
  75% { transform: translateY(-4px) rotate(8deg); }
}
@keyframes boom-pulse {
  0%, 100% { box-shadow: var(--shadow-coral-glow); }
  50% { box-shadow: 0 4px 22px rgba(239,108,74,.6); }
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(220px) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .banner, .total-cell .crown, .banner .crown, .bust-btn.active, .confetti i { animation: none !important; }
}
