/* Chemcards Modern Clean Lab - Physical Playing Cards & Table Styles */

/* Table Mat Light Mode */
.table {
  min-height: 285px;
  border-radius: 22px 22px 80px 80px;
  padding: 18px 30px 15px;
  overflow: visible;
  background: #e6f0ed;
  border: 1px solid #cadfd9;
  box-shadow: 0 4px 20px -2px rgba(44, 76, 64, 0.06), inset 0 2px 6px rgba(255, 255, 255, 0.7);
  color: #0f172a;
  position: relative;
}

.table:before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid #b0cdc5;
  border-radius: 16px 16px 70px 70px;
  pointer-events: none;
}

.play-field {
  min-height: 175px;
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 35px;
  position: relative;
}

.table-bottom {
  padding: 10px 20px 0;
  display: flex;
  justify-content: space-between;
  color: #64748b;
  font-size: 11px;
  position: relative;
  border-top: 1px solid #cadfd9;
}

/* Turn Ribbon Banner */
.turn-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding: 12px 18px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  color: #065f46;
  box-shadow: 0 1px 3px rgba(5, 150, 105, 0.08);
}

.turn-ribbon strong {
  color: #047857;
  font-size: 14px;
  font-weight: 600;
}

.turn-timer {
  font: 600 13px/1 ui-monospace, monospace;
  background: #d1fae5;
  color: #047857;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #a7f3d0;
  letter-spacing: 0.5px;
}

.turn-timer.urgent {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fca5a5;
  animation: pulse-urgent 0.8s infinite alternate;
}

@keyframes pulse-urgent {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.turn-ribbon span {
  font-size: 12px;
  color: #065f46;
}

.hand-head {
  margin: 14px 0 0;
}

/* Physical Hand Container */
.physical-hand {
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: visible;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

/* Playing Card Surface & Elevation */
.playing-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  background: var(--card, #ffffff);
  color: var(--ink, #0f172a);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  transform: rotate(var(--angle));
  transform-origin: 50% 100%;
  z-index: var(--order);
  transition: transform .14s ease, box-shadow .14s ease;
  touch-action: pan-y;
  padding: 0;
  text-align: left;
}

.playing-card:before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid currentColor;
  opacity: .18;
  border-radius: 4px;
  pointer-events: none;
}

.playing-card:hover {
  transform: translateY(-7px) rotate(var(--angle));
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12), 0 2px 4px rgba(15, 23, 42, 0.06);
  filter: none !important;
}

/* Selected State: Lift -14px, Deep Shadow, 2px Emerald Ring */
.playing-card.selected {
  transform: translateY(-14px) rotate(var(--angle));
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15), 0 0 0 2px #059669;
  touch-action: none;
}

.playing-card.selected:hover {
  transform: translateY(-17px) rotate(var(--angle));
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18), 0 0 0 2px #059669;
}

.playing-card.card-highlight {
  transform: translateY(-12px) rotate(var(--angle));
  box-shadow: 0 8px 20px rgba(4, 120, 87, 0.25), 0 0 0 2px #047857;
  border-color: #047857;
  z-index: 80 !important;
}

/* Card Typography */
.card-corner {
  position: absolute;
  left: 7px;
  top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.card-corner b {
  font: 600 21px/1.1 Georgia, serif;
}

.card-corner small {
  font: 10px/1.4 ui-monospace, monospace;
  letter-spacing: -0.2px;
}

.card-center {
  position: absolute;
  inset: 41px 6px 20px;
  display: flex;
  flex-direction: column;
  text-align: center;
  justify-content: center;
}

.card-center strong {
  font: 39px/1 Georgia, serif;
}

.card-center span {
  font-size: 10px;
  margin-top: 4px;
  font-weight: 500;
}

.card-center small {
  font: 10px/1.5 ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.card-bottom {
  position: absolute;
  bottom: 6px;
  right: 7px;
  transform: rotate(180deg);
  font: 18px Georgia, serif;
}

/* Card Picked Circular Badge */
.card-picked {
  position: absolute;
  right: 6px;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #059669;
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: bold;
  opacity: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: opacity .12s ease;
}

.selected .card-picked {
  opacity: 1;
}

/* Sweeping & Dragging Transitions */
.sweeping .playing-card,
.dragging .playing-card {
  transition: none;
}

.physical-hand.dragging .selected {
  opacity: .45;
}

.dealing .playing-card {
  animation: physical-deal .43s both cubic-bezier(.2, .7, .2, 1);
  animation-delay: var(--deal-delay);
}

@keyframes physical-deal {
  from {
    opacity: 0;
    translate: 50px 100px;
    rotate: 12deg;
  }
  to {
    opacity: 1;
    translate: 0 0;
    rotate: 0deg;
  }
}

.physical-hand.returning {
  animation: card-return .25s;
}

@keyframes card-return {
  0%, 100% {
    translate: 0 0;
  }
  35% {
    translate: -6px 0;
  }
  70% {
    translate: 6px 0;
  }
}

/* Composer Bar */
.composer {
  position: sticky;
  bottom: 12px;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  padding: 14px 18px;
}

.match-list {
  margin-top: 10px;
}

.match {
  padding: 8px 13px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: all .15s ease;
}

.match:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.match.active {
  border-color: #059669;
  background: #ecfdf5;
  color: #065f46;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.match strong {
  font-size: 18px;
  color: #0f172a;
}

.match.active strong {
  color: #065f46;
}

/* Card Drag Ghost */
.card-drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  width: 90px;
  height: 126px;
  transform: translate(-40%, -40%);
}

.card-drag-ghost > span {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  background: var(--card, #ffffff);
  color: var(--ink, #0f172a);
  border-radius: 7px;
  box-shadow: 0 16px 32px -4px rgba(15, 23, 42, 0.22), 0 6px 12px -2px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.15);
  font: 39px Georgia, serif;
  transform: translate(calc(var(--i) * 7px), calc(var(--i) * -4px)) rotate(calc(var(--i) * 4deg));
}

.card-drag-ghost > b {
  position: absolute;
  bottom: -26px;
  left: 10px;
  font: 12px system-ui, -apple-system, sans-serif;
  background: #059669;
  color: #ffffff;
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
}

/* Drag & Drop Feedback Overlay */
.drop-message {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 26px;
  letter-spacing: 2px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: inherit;
  border: 2px dashed #cbd5e1;
  color: #0f172a;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

.drop-message span {
  font-size: 12px;
  letter-spacing: 0;
  color: #64748b;
  margin-top: 8px;
}

.table.drop-ready .drop-message,
.table.drop-over .drop-message,
.table.drop-invalid .drop-message {
  display: flex;
}

.table.drop-ready:not(.drop-over):not(.drop-invalid) .drop-message {
  opacity: .7;
}

.table.drop-over .drop-message {
  opacity: 1;
  background: #ecfdf5;
  border-color: #047857;
  color: #047857;
}

.table.drop-over .drop-message span {
  color: #047857;
}

.table.drop-invalid .drop-message {
  opacity: 1;
  background: #fff1f2;
  border-color: #be123c;
  color: #be123c;
}

.table.drop-invalid .drop-message:after {
  content: '松手后保留选牌，继续调整组合';
  font-size: 12px;
  letter-spacing: 0;
  margin-top: 10px;
  color: #be123c;
  font-weight: 500;
}

.table.drop-invalid .drop-message span {
  display: none;
}

/* Flying Cards Animation */
.flying-card {
  position: fixed;
  width: 54px;
  height: 76px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--card, #ffffff);
  color: var(--ink, #0f172a);
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
  font: 28px Georgia, serif;
  pointer-events: none;
  z-index: 2000;
}

/* Opponent Hand Card Backs */
.opponent-backs {
  display: flex;
  height: 15px;
  margin-top: 4px;
  padding-left: 4px;
}

.opponent-backs:empty {
  display: none;
}

.opponent-backs i {
  width: 11px;
  height: 16px;
  border: 1px solid #cbd5e1;
  background: #94a3b8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
  transform: rotate(6deg);
  border-radius: 2px;
  margin-left: -3px;
}

.player {
  position: relative;
  padding: 6px 12px;
}

/* Played Substance Display */
.played {
  padding: 14px 28px;
  border-radius: 12px;
  transform: rotate(-1.5deg);
  min-width: 220px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.played-formula {
  font-size: 33px;
  color: #0f172a;
}

.played-atom-cards {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  margin: 12px 0 2px;
}

.played-atom-cards > span {
  width: 30px;
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: var(--card, #ffffff);
  color: var(--ink, #0f172a);
  display: grid;
  place-items: center;
  font: 19px Georgia, serif;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08);
  transform: rotate(var(--turn));
  margin-left: -3px;
}

.played-atom-cards small {
  font: 12px monospace;
  margin-left: 6px;
}

.played-meta {
  margin-top: 6px;
}

/* Draw Pile (Mode B Solitaire) */
.draw-pile {
  position: absolute;
  left: 10px;
  top: calc(50% - 40px);
  width: 55px;
  height: 78px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 3px 3px 0 #e2e8f0, 6px 6px 0 #cbd5e1, 0 6px 14px rgba(15, 23, 42, 0.08);
  color: #0f172a;
  display: grid;
  place-items: center;
  transform: rotate(-7deg);
  padding: 8px;
}

.draw-pile > span {
  font: bold 28px Georgia, serif;
  color: #059669;
}

.draw-pile > small {
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
}

.draw-pile:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.draw-pile:hover:not(:disabled) {
  transform: translateY(-4px) rotate(-7deg);
  box-shadow: 3px 6px 0 #e2e8f0, 6px 9px 0 #cbd5e1, 0 10px 18px rgba(15, 23, 42, 0.12);
}

/* Responsive Styles */
@media(min-width: 1450px) {
  .table {
    min-height: 300px;
  }
  .play-field {
    min-height: 195px;
  }
}

@media(max-width: 800px) {
  .table {
    padding: 13px 12px 12px;
    min-height: 240px;
    border-radius: 15px 15px 37px 37px;
  }
  .table:before {
    border-radius: 10px 10px 32px 32px;
  }
  .play-field {
    min-height: 155px;
    padding: 13px 0;
  }
  .table-bottom {
    padding: 9px 7px 0;
  }
  .hand-head {
    margin: 10px 0 0;
  }
  .hand-head h2 {
    font-size: 14px;
  }
  .physical-hand {
    margin-top: 4px;
  }
  .card-corner b {
    font-size: 18px;
  }
  .card-corner {
    left: 6px;
    top: 6px;
  }
  .card-center {
    inset: 36px 5px 18px;
  }
  .card-center strong {
    font-size: 31px;
  }
  .card-center small {
    font-size: 9px;
  }
  .card-bottom {
    font-size: 15px;
  }
  .playing-card {
    border-radius: 6px;
  }
  .playing-card.selected {
    transform: translateY(-12px) rotate(var(--angle));
  }
  .composer {
    bottom: 6px;
    margin-top: 6px;
    padding: 12px;
  }
  .composer-top {
    gap: 9px;
  }
  .composer-actions .btn {
    padding: 9px 14px;
  }
  .played {
    padding: 13px 19px;
    min-width: 190px;
  }
  .played-formula {
    font-size: 28px;
  }
  .played-atom-cards > span {
    width: 25px;
    height: 34px;
    font-size: 16px;
  }
  .played-atom-cards {
    margin-top: 9px;
  }
  .draw-pile {
    width: 37px;
    height: 57px;
    left: 0;
    top: calc(50% - 28px);
    padding: 3px;
  }
  .draw-pile > span {
    font-size: 23px;
  }
  .draw-pile > small {
    font-size: 8px;
  }
  .context-card {
    max-width: calc(100% - 76px);
    margin-left: 35px;
  }
  .context-atom {
    font-size: 19px;
    padding: 5px 7px;
  }
  .context-atoms {
    gap: 6px;
  }
  .context-atom small {
    font-size: 11px;
  }
  .turn-caption {
    font-size: 11px;
  }
  .opponent-backs {
    height: 12px;
  }
  .opponent-backs i {
    height: 13px;
    width: 9px;
  }
  .drop-message {
    font-size: 21px;
  }
  .card-drag-ghost {
    width: 70px;
    height: 98px;
  }
}

@media(prefers-reduced-motion: reduce) {
  .playing-card,
  .physical-hand,
  .dealing .playing-card {
    animation: none !important;
    transition: none !important;
  }
}

@media(max-width: 800px) {
  .physical-hand {
    max-height: 290px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 12px;
  }
  .composer {
    position: relative;
    bottom: auto;
  }
  .physical-hand:after {
    content: '';
    display: block;
    position: absolute;
    top: 100%;
    height: 12px;
    width: 1px;
  }
}

/* Candidate drawer and local collection share the restrained table styling. */
.candidate-list{max-height:220px;overflow:auto;align-content:flex-start;padding:3px;scrollbar-width:thin}
.collection-tools{display:flex;gap:10px;flex-wrap:wrap;margin:15px 0}
.undiscovered{opacity:.65}.discovered{border-left:3px solid #047857}
.feedback-toggle{display:flex;align-items:center;gap:12px;margin:20px 0;font-size:16px}
.feedback-toggle input{width:20px;height:20px;accent-color:#047857}
.pool-table{width:100%;border-collapse:collapse;font-size:14px}
.pool-table th,.pool-table td{padding:9px 12px;text-align:left;border-bottom:1px solid #e2e8f0}
.playing-card:focus-visible{outline:3px solid #047857;outline-offset:2px}
.welcome .eyebrow{text-transform:none;letter-spacing:.08em}
.deck-control{position:relative}.deck-control output{float:right;color:#047857;font-weight:600}
.deck-control input[type=range]{width:100%;height:24px;padding:0;accent-color:#047857;background:transparent;box-shadow:none;border:0;cursor:pointer}
.deck-marks{display:flex;justify-content:space-between;font-size:11px;color:#64748b}
.collection-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(125px,1fr));gap:10px;margin-top:16px}
.collection-tile{position:relative;aspect-ratio:1;min-width:0;padding:13px 8px;border:1px solid #e2e8f0;border-radius:10px;background:#f8fafc;display:flex;flex-direction:column;justify-content:center;gap:9px;text-align:center;color:#475569;overflow:hidden}
.collection-tile div{display:flex;flex-direction:column;gap:10px;min-width:0}
.collection-tile strong{font:22px Georgia;overflow-wrap:anywhere}.collection-tile span{font-size:12px;overflow-wrap:anywhere}
.collection-tile small{font-size:10px;color:#64748b}.collection-tile.undiscovered{opacity:1;background:repeating-linear-gradient(135deg,#f8fafc,#f8fafc 6px,#f5f7fa 6px,#f5f7fa 7px)}
.collection-tile.discovered{border:1px solid #6eac96;background:#edf8f2;color:#064e3b;box-shadow:0 2px 7px #0478570c}
.collection-tile.discovered:after{content:'✓';position:absolute;right:7px;top:4px;font-size:12px;color:#047857}
.collection-tile:hover{border-color:#047857;transform:translateY(-2px)}
.finish-metal{background-image:linear-gradient(115deg,#ffffff08 5%,#ffffff66 23%,#00000015 39%,#ffffff44 54%,#0000000d 72%,#ffffff38 90%),repeating-linear-gradient(0deg,#ffffff12 0px,#ffffff12 1px,transparent 1px,transparent 3px)}
.finish-metal:after{content:'';position:absolute;inset:1px;border-radius:inherit;background:linear-gradient(110deg,transparent 28%,#ffffff00 36%,#ffffff60 48%,#ffffff00 60%,transparent 70%);background-size:280% 100%;background-position:100% 0;pointer-events:none;opacity:.55;transition:background-position .7s ease}
.finish-metal:hover:after,.finish-metal.selected:after{background-position:0 0}
.finish-metal.finish-gold:after{background:linear-gradient(110deg,transparent 28%,#fef08a00 36%,#fef08ab0 48%,#fef08a00 60%,transparent 70%);background-size:280% 100%;}
.finish-metal.finish-copper:after{background:linear-gradient(110deg,transparent 28%,#fdba7400 36%,#fdba74b0 48%,#fdba7400 60%,transparent 70%);background-size:280% 100%;}
.finish-graphite{background-image:repeating-linear-gradient(125deg,#ffffff06 0,#ffffff06 1px,transparent 1px,transparent 4px);box-shadow:0 3px 6px #0003,inset 0 0 20px #0002}
.finish-gas{background-image:radial-gradient(ellipse at 80% 15%,#ffffffaa,transparent 70%)}
.finish-crystal{background-image:linear-gradient(150deg,#ffffff22 20%,transparent 20%,transparent 64%,#ffffff18 64%)}
.substance-effect{position:absolute;inset:0;border-radius:inherit;pointer-events:none;z-index:8;background:radial-gradient(ellipse at 50% 65%,color-mix(in srgb,var(--effect-color) 20%,transparent),transparent 68%);animation:substance-glow 2.4s ease both}
.effect-caption{position:absolute;bottom:34px;left:50%;transform:translateX(-50%);white-space:nowrap;background:#ffffffeb;border:1px solid color-mix(in srgb,var(--effect-color) 35%,white);color:var(--effect-color);padding:5px 10px;border-radius:20px;font-size:11px;box-shadow:0 2px 12px #0001}
.substance-effect i{position:absolute;width:6px;height:9px;background:var(--effect-color);clip-path:polygon(50% 0,100% 40%,65% 100%,0 70%);animation:crystal-settle 1.8s ease-out both;animation-delay:calc(var(--i)*25ms)}
@keyframes substance-glow{0%,100%{opacity:0}20%,65%{opacity:1}}
@keyframes crystal-settle{from{opacity:0;transform:translateY(-25px) rotate(0)}35%{opacity:.7}to{opacity:0;transform:translateY(50px) rotate(45deg)}}
.effects-off .finish-metal:after{display:none}
@media(prefers-reduced-motion:reduce){.finish-metal:after{transition:none}.substance-effect,.substance-effect i{animation:none}.substance-effect i{display:none}}
@media(max-width:800px){.brand strong{font-size:16px}.brand{gap:5px}.topbar{padding-inline:10px}.top-actions .quiet{padding-inline:5px}.collection-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}.collection-tile{padding:12px 5px}.collection-tile strong{font-size:19px}.collection-tile small{font-size:9px}.collection-tile span{font-size:11px}}
@media(max-width:800px){.top-actions .quiet{padding:8px 6px;font-size:11px}.brand-note{display:none}.turn-ribbon{flex-wrap:wrap}.hand-head{gap:8px}.candidate-list{max-height:190px}.field-grid{grid-template-columns:1fr}.hand-tools{flex-wrap:wrap}}
