@font-face {
  font-family: 'Figtree';
  src: url('../shared/fonts/figtree.woff2') format('woff2');
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --felt: #12684a;
  --felt-deep: #0a3a2a;
  --back: #b2343f;
  --back-2: #8a2430;
  --ink: #f4f6f2;
  --muted: #a9c5b8;
  --gold: #f4c04e;
  --red: #c8202f;
  --black: #1b1d24;
  --cw: 48px;
  --ch: 68px;
}
body[data-table='ocean'] { --felt: #1d5a86; --felt-deep: #0c2a44; }
body[data-table='plum'] { --felt: #5b2b66; --felt-deep: #26102c; }
body[data-table='slate'] { --felt: #3a4650; --felt-deep: #151b20; }
body[data-table='sand'] { --felt: #9a7a4c; --felt-deep: #4a3519; }
body[data-back='navy'] { --back: #27407a; --back-2: #182a52; }
body[data-back='forest'] { --back: #2d6b44; --back-2: #1a4329; }
body[data-back='ink'] { --back: #2a2a33; --back-2: #121218; }

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: 'Figtree', system-ui, sans-serif;
  color: var(--ink);
  background: var(--felt-deep);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
body { background: radial-gradient(140% 90% at 50% 30%, var(--felt), var(--felt-deep) 85%); }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  max-width: 760px;
  margin: 0 auto;
}

.bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 8px 8px 4px;
  gap: 8px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.stats { display: flex; justify-content: center; gap: 22px; }
.stats div { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.stats small { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 600; }
.stats b { font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; }
.deal-tag { font-size: 11px; font-weight: 700; color: var(--gold); text-align: right; line-height: 1.15; }

.board { flex: 1; position: relative; min-height: 0; }

.slot {
  position: absolute;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.1);
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.08);
  display: grid;
  place-items: center;
}
.slot svg { width: 46%; height: 46%; fill: rgba(255, 255, 255, 0.16); }
.slot.stock { cursor: pointer; }
.slot.stock svg { fill: none; stroke: rgba(255, 255, 255, 0.35); stroke-width: 2; stroke-linecap: round; }

.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.1);
  transition: transform 0.24s cubic-bezier(0.25, 0.8, 0.3, 1);
  will-change: transform;
  cursor: pointer;
}
.card.dragging { transition: none; }
.card .face, .card .back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.2);
}
.card.down .face { display: none; }
.card:not(.down) .back { display: none; }
.card.flip { animation: flip 0.24s ease; }
@keyframes flip { 0% { filter: brightness(0.7); } 100% { filter: none; } }
.card.hint .face { box-shadow: 0 0 0 3px var(--gold), 0 4px 12px rgba(0, 0, 0, 0.4); }
.card.shake { animation: shake 0.28s ease; }
@keyframes shake { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }

.face {
  background: #fffdf8;
  color: var(--black);
  overflow: hidden;
}
.face.red { color: var(--red); }
.face svg { fill: currentColor; display: block; }
.face .tl {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 3%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 27%;
}
.face .tl b { font-weight: 800; font-size: calc(var(--cw) * 0.36); letter-spacing: -1px; line-height: 1; }
.face .tl svg { width: calc(var(--cw) * 0.27); height: calc(var(--cw) * 0.27); }
.face .mid { position: absolute; left: 22%; right: 22%; top: 38%; bottom: 10%; display: grid; place-items: center; }
.face .mid svg { width: 100%; height: 100%; }
.face .court {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 34%;
  bottom: 7%;
  border-radius: calc(var(--cw) * 0.06);
  background: currentColor;
  display: grid;
  place-items: center;
}
.face .court span { color: #fffdf8; font-weight: 800; font-size: calc(var(--cw) * 0.42); line-height: 1; }
.face .court svg { position: absolute; width: 34%; height: 34%; right: 8%; bottom: 8%; fill: #fffdf8; opacity: 0.85; }

.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.14) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 7px),
    linear-gradient(160deg, var(--back), var(--back-2));
  border: calc(var(--cw) * 0.06) solid #fffdf8;
}

.tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px 8px;
  gap: 6px;
}
.tool {
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.2);
  border: 0;
  border-radius: 14px;
  padding: 8px 4px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.tool:active { background: rgba(0, 0, 0, 0.32); }
.tool:disabled { opacity: 0.4; }
.tool svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool em { font-style: normal; color: var(--gold); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(2, 16, 10, 0.6);
  backdrop-filter: blur(3px);
  animation: fade 0.18s ease;
}
.sheet[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet-card {
  width: min(360px, 100%);
  max-height: 100%;
  background: #f8f6f0;
  color: #1d2a24;
  border-radius: 20px;
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.sheet-card.scroll { overflow-y: auto; }
@keyframes rise { from { transform: translateY(16px) scale(0.97); opacity: 0; } }
.sheet-card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.sheet-card p { margin: 0; line-height: 1.5; color: #3f4f47; }
.note { font-size: 13px; color: #6b7b72 !important; margin-top: -4px !important; }

.btn {
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  border: 0;
  border-radius: 13px;
  padding: 13px;
  background: #e8e5dc;
  color: #1d2a24;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: #12684a; color: #fff; }
.btn.reward { background: var(--gold); color: #3b2800; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: #e8e5dc; padding: 4px; border-radius: 13px; gap: 4px; }
.seg button { font: inherit; font-weight: 700; font-size: 15px; border: 0; border-radius: 10px; padding: 10px; background: transparent; color: #4b5a52; cursor: pointer; }
.seg button.on { background: #fff; color: #12684a; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.small-link { text-align: center; color: #6b7b72; font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 8px; }
.stat-grid div { background: #eeebe3; border-radius: 12px; padding: 10px 12px; }
.stat-grid dt { font-size: 12px; color: #6b7b72; font-weight: 650; }
.stat-grid dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; color: #12684a; }
.stat-grid.small dd { font-size: 18px; }

.kicker { text-align: center; font-weight: 700; color: #12684a !important; letter-spacing: 0.4px; }
.big-score { text-align: center; font-size: 56px; font-weight: 900; line-height: 1; color: #1d2a24; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.themes h3 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 13px; color: #6b7b72; text-transform: uppercase; letter-spacing: 0.8px; }
.theme {
  font: inherit;
  height: 70px;
  border-radius: 12px;
  border: 3px solid transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 5px;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.theme.on { border-color: var(--gold); }
.theme small { font-size: 10px; font-weight: 600; opacity: 0.9; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #f8f6f0;
  color: #1d2a24;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 6000;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast[hidden] { display: none; }
