/* ============================================================
 * TrueTool /cards/ 閳?shared card game UI styles (deck.js).
 * Load after style.css (depends on its CSS variables).
 * ============================================================ */

/* ===== Game shell ===== */
.ttc-game {
  background: linear-gradient(180deg, #FBEFE8 0%, #F6F5F1 100%);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0 1.5rem;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-user-select: none;
}
.ttc-game * { box-sizing: border-box; }

.ttc-bar {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  align-items: center; justify-content: center;
  margin: 0.25rem 0 0.75rem;
}
.ttc-stat {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: #fff; border: 1px solid var(--c-border); border-radius: 8px;
  padding: 0 0.9rem; min-height: 44px;
  font-size: 0.85rem; color: var(--c-text-secondary);
}
.ttc-stat b { color: var(--c-text); }

/* ===== Cards ===== */
.ttc-card {
  position: relative;
  width: var(--ttc-w, 80px);
  height: calc(var(--ttc-w, 80px) * 1.4);
  flex: none;
  background: #fff;
  border: 1px solid #C9C6BB;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.ttc-card.red { color: #E03131; }
.ttc-card.black { color: #1A1B1E; }
.ttc-card.ttc-sm { width: calc(var(--ttc-w, 80px) * 0.8); height: calc(var(--ttc-w, 80px) * 1.4 * 0.8); }

.ttc-corner {
  position: absolute;
  font-size: calc(var(--ttc-w, 80px) * 0.22);
  font-weight: 700; text-align: center;
}
.ttc-corner br { display: block; }
.ttc-tl { top: 3px; left: 4px; }
.ttc-br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.ttc-pip {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--ttc-w, 80px) * 0.5);
}

/* Face-down card back — classic red back with white frame and
   subtle diamond lattice (no image assets). */
.ttc-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0) 0 24%, rgba(255,255,255,.55) 25% 27%, rgba(255,255,255,0) 28%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.15) 0 5px, rgba(255,255,255,0) 5px 10px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.15) 0 5px, rgba(255,255,255,0) 5px 10px),
    #C22A2A;
  border: 2px solid #fff;
  box-shadow: inset 0 0 0 1px #8F2323, 0 1px 2px rgba(0,0,0,.15);
}

/* Interactive states */
button.ttc-card, .ttc-card.ttc-clickable {
  cursor: pointer;
  border: 1px solid #8B909A;
}
button.ttc-card {
  padding: 0; background: #fff; font: inherit;
}
.ttc-card.ttc-clickable:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0,0,0,.18);
  border-color: var(--c-primary);
}
.ttc-card.ttc-picked {
  outline: 3px solid var(--c-primary);
  outline-offset: 1px;
}
.ttc-card.ttc-dim { opacity: 0.45; }
.ttc-card.ttc-flash { animation: ttcFlash .45s ease; }
@keyframes ttcFlash {
  0% { box-shadow: 0 0 0 4px rgba(220, 38, 38, .55); }
  100% { box-shadow: 0 1px 2px rgba(0,0,0,.12); }
}
.ttc-card.ttc-fly {
  animation: ttcFly .45s ease;
}
@keyframes ttcFly {
  0% { transform: translateY(-14px) scale(1.05); }
  60% { transform: translateY(3px) scale(.98); }
  100% { transform: translateY(0) scale(1); }
}

/* ===== Layout rows / zones ===== */
.ttc-row {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
  align-items: flex-start; justify-content: center;
}
.ttc-zone {
  background: rgba(255,255,255,.75);
  border: 1px dashed #C9C6BB;
  border-radius: 10px;
  padding: 0.6rem 0.45rem;
  min-height: calc(var(--ttc-w, 80px) * 1.4 + 1.2rem);
  margin: 0.5rem 0;
}
.ttc-zone-label {
  display: block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--c-text-secondary); text-align: center; margin-bottom: 0.35rem;
}
.ttc-hand {
  display: flex; gap: 0.4rem;
  overflow-x: auto; overflow-y: hidden;
  padding: 0.6rem 0.25rem 0.9rem;
  justify-content: flex-start;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ttc-hand::-webkit-scrollbar { display: none; }

/* Overlapping stacks (hands and table piles): later cards sit on top,
   hover/focus lifts a card above its neighbours. */
.ttc-overlap {
  display: flex; gap: 0;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: flex-start;
  padding: 0.6rem 0.25rem 0.9rem;
}
.ttc-overlap::-webkit-scrollbar { display: none; }
.ttc-overlap .ttc-card {
  position: relative;
  transition: transform .15s, box-shadow .15s, border-color .15s, z-index 0s;
}
.ttc-overlap .ttc-card + .ttc-card { margin-left: calc(var(--ttc-w, 80px) * -0.6); }
.ttc-overlap .ttc-card:hover,
.ttc-overlap .ttc-card:focus,
.ttc-overlap .ttc-card.ttc-picked {
  transform: translateY(-10px);
  z-index: 5;
}
@media (max-width: 640px) {
  .ttc-overlap .ttc-card + .ttc-card { margin-left: calc(var(--ttc-w, 54px) * -0.6); }
}

.ttc-msg {
  text-align: center; font-size: 0.9rem; font-weight: 600;
  color: var(--c-text); min-height: 1.4em; margin: 0.4rem 0;
}

/* ===== Result overlay ===== */
.ttc-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.ttc-overlay-box {
  background: #fff; border-radius: 14px; padding: 1.5rem 1.75rem;
  max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.ttc-overlay-box h2 { margin: 0 0 0.5rem; }
.ttc-overlay-box p { margin-bottom: 1rem; }

/* ===== Rule source card ===== */
.ttc-source {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.ttc-source summary {
  cursor: pointer; font-weight: 700; color: var(--c-text);
}
.ttc-source table {
  width: 100%; border-collapse: collapse; margin-top: 0.75rem;
  font-size: 0.88rem;
}
.ttc-source th, .ttc-source td {
  border: 1px solid var(--c-border);
  padding: 0.5rem 0.7rem; text-align: left; vertical-align: top;
}
.ttc-source th { width: 32%; background: #F6F5F1; color: var(--c-text-secondary); font-weight: 600; }
.ttc-source td { color: var(--c-text); }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  :root { --ttc-w: 54px; }
  .ttc-row { gap: 0.3rem; }
  .ttc-hand { gap: 0.3rem; }
}
