:root {
  --bg: #0c1220;
  --surface: #151e31;
  --surface-2: #1c2840;
  --border: #2a3958;
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --gold: #eab308;
  --green: #22c55e;
  --red: #f43f5e;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.app {
  max-width: 584px;
  margin: 0 auto;
  padding: 12px 14px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
}

.user-name {
  font-weight: 600;
  font-size: 15px;
}

.conn-status {
  font-size: 12px;
  color: var(--green);
}

.conn-status.offline {
  color: var(--gold);
}

.dev-bar select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}

.hero {
  background: linear-gradient(160deg, #18233a 0%, #101829 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
}

.hero-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
}

.hero h1 {
  margin: 4px 0 6px;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 13px;
}

.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.queue-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.4);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.join-code-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

input,
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #ca8a04, #eab308);
  color: #0b0f19;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

.btn-ghost {
  background: transparent;
  padding: 8px 10px;
}

.btn-sm {
  padding: 7px 11px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 16px;
}

.section {
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.room-card.your-turn {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.room-card-title {
  font-weight: 600;
  font-size: 15px;
}

.room-card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.badge.turn {
  background: rgba(34, 197, 94, 0.16);
  border-color: var(--green);
  color: #86efac;
}

.badge.waiting {
  background: rgba(234, 179, 8, 0.15);
  border-color: var(--gold);
  color: #fde047;
}

.empty-state {
  text-align: center;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Room View */
.room-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.room-meta-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.player-card.active {
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.25);
}

.player-card-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card-sub {
  font-size: 12px;
  color: var(--muted);
}

.timer-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  white-space: nowrap;
}

.timer-pill.overdue {
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
}

.status-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.game-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Tic-Tac-Toe 3-Piece Board */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 300px;
}

.ttt-cell {
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  padding: 0;
  color: var(--text);
  transition: border-color 0.15s, transform 0.08s;
}

.ttt-cell:hover:not(:disabled) {
  border-color: var(--accent);
}

.ttt-cell:active:not(:disabled) {
  transform: scale(0.96);
}

.ttt-cell:disabled {
  cursor: default;
}

.ttt-cell.last-move {
  border-color: var(--gold);
}

.ttt-cell.win-cell {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.16);
}

.ttt-cell.fading svg {
  opacity: 0.38;
  animation: pulseFade 1.4s ease-in-out infinite;
}

.ttt-cell .fade-tag {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  font-weight: 700;
}

@keyframes pulseFade {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.65;
  }
}

.ttt-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.room-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.log-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.log-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
  font-size: 13px;
}

.log-item {
  color: #cbd5e1;
}

.log-time {
  color: var(--muted);
  font-size: 11px;
  margin-right: 6px;
}

/* Modal */
dialog.modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  width: min(92vw, 400px);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

.checkbox-field input {
  width: auto;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

/* Flip 7 */
.f7-wrap,
.cc-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.f7-meta,
.cc-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 7px 10px;
  border-radius: 9px;
}

.f7-event {
  font-size: 13px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 9px;
  padding: 8px 10px;
  color: #e0f2fe;
}

.f7-pending {
  background: rgba(234, 179, 8, 0.14);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 10px;
}

.f7-pending-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.f7-target-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.f7-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.f7-player {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 10px;
}

.f7-player.is-turn {
  border-color: var(--green);
}

.f7-player.is-busted {
  opacity: 0.65;
  border-color: rgba(244, 63, 94, 0.45);
}

.f7-player-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.f7-pname {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.f7-st {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.f7-st-active { color: #86efac; }
.f7-st-stayed { color: #fde047; }
.f7-st-frozen { color: #7dd3fc; }
.f7-st-busted { color: #fda4af; }

.f7-pscore {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.f7-hand-pts {
  color: var(--green);
  font-weight: 700;
}

.f7-total-pts {
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 7px;
  font-weight: 700;
}

.f7-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 30px;
  align-items: center;
}

.f7-empty {
  font-size: 12px;
  color: var(--muted);
}

.f7-card {
  min-width: 30px;
  height: 32px;
  padding: 0 7px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.f7-num-0 { background: #334155; color: #f8fafc; }
.f7-num-1 { background: #0369a1; color: #e0f2fe; }
.f7-num-2 { background: #15803d; color: #dcfce7; }
.f7-num-3 { background: #b45309; color: #fef3c7; }
.f7-num-4 { background: #be123c; color: #ffe4e6; }
.f7-mod { background: #6d28d9; color: #ede9fe; font-size: 12px; }
.f7-mod-x2 { background: #ca8a04; color: #0b0f19; }
.f7-sc { background: #0f766e; font-size: 14px; }

.f7-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
}

/* Castle Combo */
.cc-keybar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cc-market-sec {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px;
}

.cc-market-sec.is-messenger {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.25);
}

.cc-market-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 7px;
}

.cc-market-head small {
  color: var(--muted);
  font-weight: 400;
}

.cc-msg-badge {
  font-size: 11px;
  color: #fde047;
  background: rgba(234, 179, 8, 0.16);
  padding: 2px 7px;
  border-radius: 999px;
}

.cc-market-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.cc-card {
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 98px;
}

.cc-card:disabled {
  cursor: default;
  opacity: 0.78;
}

.cc-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.cc-row-castle {
  border-top: 3px solid #a855f7;
}

.cc-row-village {
  border-top: 3px solid #22c55e;
}

.cc-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.cc-cost {
  font-weight: 800;
  color: #fde047;
}

.cc-cost.cant-afford {
  color: #fda4af;
}

.cc-shields {
  font-size: 12px;
}

.cc-card-name {
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
}

.cc-card-instant {
  font-size: 10px;
  color: #7dd3fc;
}

.cc-card-score {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.25;
}

.cc-pick-bar {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cc-pick-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cc-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.cc-tab {
  flex: 1;
  min-width: 110px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 12px;
  font-weight: 600;
}

.cc-tab small {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
}

.cc-tab.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
}

.cc-tab.is-turn {
  border-left: 3px solid var(--green);
}

.cc-tableau {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.cc-slot {
  min-height: 84px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 9px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
  font-size: 11px;
  cursor: default;
}

.cc-slot.placeable {
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  background: rgba(56, 189, 248, 0.08);
}

.cc-slot.facedown {
  border-style: solid;
  background: #1e293b;
  color: var(--muted);
}

.cc-slot.cc-row-castle,
.cc-slot.cc-row-village {
  border-style: solid;
  color: var(--text);
  align-items: flex-start;
  text-align: left;
  justify-content: flex-start;
}

.cc-slot-top {
  font-size: 11px;
}

.cc-slot-name {
  font-weight: 700;
  font-size: 11px;
  line-height: 1.2;
}

.cc-slot-score {
  font-size: 9.5px;
  color: var(--muted);
  line-height: 1.2;
}

/* Castle Combo Authentic Cards & Animated Messenger */
.cc-wrap {
  --cc-scale: 1;
}

.cc-market-area {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
  align-items: stretch;
}

.cc-rows-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cc-market-row {
  display: grid;
  grid-template-columns: 44px repeat(3, calc(148px * var(--cc-scale, 1)));
  gap: 5px;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 2px solid transparent;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.cc-market-row.is-messenger {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.22);
}

.cc-messenger-track {
  position: relative;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  padding: 8px 2px;
}

.cc-messenger-pawn {
  position: absolute;
  left: 3px;
  right: 3px;
  height: 54px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0b0f19;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.45);
  transition: top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cc-messenger-pawn small {
  font-size: 8.5px;
  font-weight: 800;
  margin-top: 2px;
}

.cc-messenger-pawn.at-castle {
  top: 18%;
}

.cc-messenger-pawn.at-village {
  top: 66%;
}

/* Card Back (Deck & Face-down) */
.cc-deck-slot {
  display: flex;
}

.cc-deck-back,
.cc-placed-back {
  width: 100%;
  border-radius: 9px;
  padding: 5px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.22);
}

.cc-back-castle {
  background: linear-gradient(160deg, #94a3b8 0%, #64748b 100%);
  color: #0f172a;
}

.cc-back-village {
  background: linear-gradient(160deg, #d4a373 0%, #a97142 100%);
  color: #1c1208;
}

.cc-back-banner {
  background: #1e293b;
  color: #fde047;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

.cc-back-emblem {
  font-size: 22px;
}

.cc-back-count {
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-weight: 800;
  font-size: 11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.cc-back-sub {
  font-size: 10px;
  font-weight: 700;
}

/* Authentic Castle Combo Card */
.cc-real-card {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: visible;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  border: 2px solid #475569;
  cursor: pointer;
  color: #1e293b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}

.cc-real-card:disabled {
  cursor: default;
}

.cc-real-card.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.55);
  transform: translateY(-2px);
}

.cc-theme-castle {
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  border-color: #64748b;
}

.cc-theme-village {
  background: linear-gradient(180deg, #f3e2c7 0%, #e2c598 100%);
  border-color: #a16207;
}

.cc-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding: 5px 5px 3px;
}

.cc-coin-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.cc-coin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fef08a, #ca8a04);
  border: 1.5px solid #422006;
  color: #1c1917;
  font-weight: 900;
  font-size: 13px;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.cc-coin.cant-afford {
  background: #fda4af;
  color: #881337;
}

.cc-coin.discounted {
  background: #86efac;
  color: #052e16;
}

.cc-msg-arrow {
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  color: #fff;
  font-weight: 900;
}

.cc-msg-arrow.to-village {
  background: #92400e;
}

.cc-msg-arrow.to-castle {
  background: #334155;
}

.cc-name-pill {
  flex: 1;
  min-width: 0;
  background: rgba(15, 23, 42, 0.86);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  padding: 4px 5px;
  border-radius: 6px;
  text-align: center;
  word-break: break-word;
}

.cc-sh-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.cc-ico {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.cc-ico-inline {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  vertical-align: middle;
}

.cc-ico-cross {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  vertical-align: middle;
}

.cc-arr-v,
.cc-arr-h {
  position: absolute;
  font-size: 9px;
  font-weight: 900;
  color: #dc2626;
  line-height: 1;
}

.cc-arr-v {
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
}

.cc-arr-h {
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
}

.cc-dir-tag {
  font-size: 10px;
  font-weight: 900;
  color: #b91c1c;
}

.cc-sym-coin {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fef08a, #ca8a04);
  border: 1.5px solid #422006;
  color: #1c1917;
  font-size: 10.5px;
  font-weight: 900;
  vertical-align: middle;
}

.cc-sym-seal {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f87171, #b91c1c);
  border: 1.5px solid #450a0a;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  vertical-align: middle;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.cc-sym-disc {
  display: inline-block;
  background: linear-gradient(135deg, #fde047, #f59e0b);
  color: #1c1917;
  border: 1px solid #78350f;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10.5px;
  font-weight: 900;
  vertical-align: middle;
}

.cc-sym-purse {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  vertical-align: middle;
  font-size: 10.5px;
  color: #78350f;
}

.cc-sym-opp {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 0 3px;
  font-size: 8.5px;
  font-weight: 800;
  vertical-align: middle;
}

.cc-purse-chip {
  margin-left: 3px;
}

.cc-body {
  padding: 4px 5px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 5px;
  flex: 1;
}

.cc-instant {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  min-height: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}

.cc-scroll {
  background: #fefce8;
  border: 1.5px solid #b45309;
  border-radius: 6px;
  padding: 4px 5px;
  font-size: 11px;
  font-weight: 800;
  color: #7f1d1d;
  line-height: 1.25;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.cc-card-scored {
  position: absolute;
  bottom: -6px;
  right: -5px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  border: 2px solid #fef2f2;
  font-size: 12px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 4;
}

/* Final Score Table & Side-by-Side Boards (Photos 2 & 3) */
.cc-final-banner {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(234, 179, 8, 0.18));
  border: 1.5px solid var(--green);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 14px;
  text-align: center;
}

.cc-score-table-wrap {
  overflow-x: auto;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: #e0f2fe;
  color: #0f172a;
}

.cc-score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.cc-score-table th,
.cc-score-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #bae6fd;
  border-right: 1px solid #bae6fd;
}

.cc-score-table th:last-child,
.cc-score-table td:last-child {
  border-right: none;
}

.cc-score-table thead th {
  background: #7dd3fc;
  color: #0c4a6e;
  font-weight: 800;
  padding: 8px 6px;
}

.cc-score-table thead th.cc-th-win {
  background: #86efac;
  color: #064e3b;
}

.cc-score-table tbody tr:nth-child(even) {
  background: #f0f9ff;
}

.cc-score-table .cc-th-icon,
.cc-score-table .cc-td-icon {
  width: 44px;
  background: #38bdf8;
  color: #0c4a6e;
  border-right: 2px solid #0284c7;
}

.cc-score-table .cc-td-pos {
  color: #0f172a;
}

.cc-score-table .cc-tr-keys td {
  border-top: 2px solid #0284c7;
}

.cc-score-table .cc-tr-total td {
  background: #7dd3fc;
  font-size: 16px;
  font-weight: 900;
  border-top: 2px solid #0284c7;
  border-bottom: none;
}

.cc-score-table .cc-tr-total td.cc-td-win {
  background: #4ade80;
  color: #052e16;
}

.cc-boards-heading {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-top: 4px;
}

.cc-final-boards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.cc-final-board-card {
  background: rgba(15, 23, 42, 0.55);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.cc-final-board-card.is-winner {
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.22);
}

.cc-final-board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 8px;
}

.cc-final-board-pts {
  color: #fde047;
}

.cc-dyn-compact {
  gap: 8px;
}

/* Player Nav & Swipeable Dynamic Grid */
.cc-player-nav {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 6px;
  align-items: center;
}

.cc-board-shell {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  touch-action: pan-y;
  overflow-x: auto;
}

.cc-lock-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  gap: 6px;
}

.cc-swipe-hint {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

.cc-dyn-grid {
  display: grid;
  gap: 6px;
  align-items: stretch;
  justify-content: center;
}

.cc-place-slot {
  min-height: 118px;
  border: 2px dashed var(--accent);
  background: rgba(56, 189, 248, 0.09);
  color: var(--accent);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 18px;
}

.cc-place-slot small {
  font-size: 10px;
}

.cc-spacer {
  min-height: 20px;
}

/* Centered Card Polish, Discard Highlight, Help Modal & Mobile Scaling */
.cc-meta {
  align-items: center;
  gap: 8px;
}

.cc-help-btn {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 8px;
}

.cc-discard-banner {
  background: rgba(244, 63, 94, 0.16);
  border: 1.5px solid var(--red);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  text-align: center;
  color: #ffe4e6;
}

.cc-market-row.is-discard-target {
  border-color: var(--red);
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.35);
}

.cc-real-card.discardable {
  cursor: pointer;
  border-color: var(--red);
}

.cc-real-card.discardable:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.55);
}

.cc-card-head {
  align-items: center;
  padding: 4px 5px 2px;
}

.cc-sh-col {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.cc-name-pill {
  flex: none;
  margin: 0 4px 3px;
  padding: 3px 4px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-instant {
  justify-content: center;
  text-align: center;
}

.cc-scroll {
  justify-content: center;
  text-align: center;
}

/* Help Modal: Shield Distribution + Symbol Legend */
.cc-help-modal {
  width: min(94vw, 480px);
  max-height: 86vh;
  overflow-y: auto;
}

.cc-help-sec {
  margin-bottom: 16px;
}

.cc-help-sec h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-dist-wrap {
  background: #fdfbf7;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.cc-dist-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 16px;
  font-weight: 900;
}

.cc-dist-table th,
.cc-dist-table td {
  padding: 7px 4px;
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #e2e8f0;
}

.cc-dist-table th:last-child,
.cc-dist-table td:last-child {
  border-right: none;
}

.cc-dist-lbl {
  text-align: left;
  padding-left: 8px !important;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  white-space: nowrap;
}

.cc-dist-sum td {
  background: #ffffff;
  border-top: 2px solid #0f172a;
  border-bottom: none;
  font-size: 17px;
}

.cc-dist-sigma {
  background: #0f172a !important;
  color: #ffffff !important;
  font-size: 18px;
}

.cc-legend-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cc-legend-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
}

.cc-legend-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.cc-legend-txt {
  font-size: 12px;
  color: var(--text);
  line-height: 1.3;
}

/* Responsive Scaling for Small Mobile / Narrow Windows */
@media (max-width: 480px) {
  .app {
    padding: 8px 8px 28px;
  }
  .game-stage {
    padding: 8px 6px;
  }
  .cc-market-area {
    grid-template-columns: 1fr 28px;
    gap: 4px;
  }
  .cc-market-row {
    grid-template-columns: 32px repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
  }
  .cc-back-banner {
    font-size: 6.5px;
    padding: 1px 2px;
  }
  .cc-back-emblem {
    font-size: 16px;
  }
  .cc-back-count {
    width: 18px;
    height: 18px;
    font-size: 9.5px;
  }
  .cc-messenger-pawn {
    height: 44px;
    font-size: 16px;
  }
  .cc-messenger-pawn small {
    display: none;
  }
  .cc-coin {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
  .cc-sh-col svg {
    width: 19px;
    height: 21px;
  }
  .cc-name-pill {
    font-size: 9.5px;
    padding: 2px 3px;
    margin: 0 3px 2px;
  }
  .cc-body {
    padding: 3px 3px 4px;
    gap: 3px;
  }
  .cc-instant,
  .cc-scroll {
    font-size: 9.5px;
    gap: 2px;
  }
  .cc-sym-coin {
    min-width: 15px;
    height: 15px;
    font-size: 9px;
  }
  .cc-sym-seal {
    min-width: 18px;
    height: 18px;
    font-size: 10px;
  }
  .cc-ico {
    max-height: 18px;
  }
  .cc-board-shell {
    padding: 6px 4px;
  }
  .cc-dyn-grid {
    gap: 4px;
  }
  .cc-place-slot {
    min-height: 92px;
    font-size: 15px;
  }
}

/* Crisp Directional Arrows Around Shields & Two-Line Deck Back Banner */
.cc-ico-col {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  vertical-align: middle;
}

.cc-ico-cross {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  vertical-align: middle;
}

.cc-arr-svg {
  position: absolute;
  pointer-events: none;
}

.cc-arr-top {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.cc-arr-bot {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.cc-arr-left {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.cc-arr-right {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.cc-back-banner {
  background: #0f172a;
  color: #fde047;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 4px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  line-height: 1;
}

.cc-back-banner > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.cc-back-banner .cc-ico-key {
  width: 11px;
  height: 16px;
}

@media (max-width: 480px) {
  .cc-back-banner {
    font-size: 9px;
    padding: 3px 2px;
    gap: 2px;
  }
  .cc-back-banner .cc-ico-key {
    width: 9px;
    height: 13px;
  }
}

/* Separate Black Pills + Big Plus on Deck Back, Two-Line Instants & Card Details */
.cc-back-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.cc-back-pill {
  background: #0f172a;
  border-radius: 6px;
  padding: 3px 4px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.cc-back-plus {
  font-size: 16px;
  font-weight: 900;
  line-height: 0.9;
  color: #0f172a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.cc-inst-line {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.cc-pick-title {
  font-size: 14px;
}

.cc-pick-row {
  color: var(--muted);
  font-size: 12px;
}

.cc-pick-desc {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cc-pick-hint {
  font-size: 11.5px;
  color: var(--muted);
}

@media (max-width: 480px) {
  .cc-back-pill {
    padding: 2px;
  }
  .cc-back-plus {
    font-size: 13px;
  }
}

/* Top Name Bar, Translucent Colored Banner & Sharpened Character Portrait */
.cc-real-card {
  min-height: 158px;
}

.cc-name-pill {
  margin: 0;
  border-radius: 8px 8px 0 0;
  padding: 4px 5px;
  font-size: 11px;
  letter-spacing: 0.01em;
}

.cc-art-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 5px 4px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.14);
}

.cc-banner-crown { background: linear-gradient(180deg, rgba(2, 132, 199, 0.28), rgba(2, 132, 199, 0.08)); }
.cc-banner-faith { background: linear-gradient(180deg, rgba(168, 85, 247, 0.28), rgba(168, 85, 247, 0.08)); }
.cc-banner-scholar { background: linear-gradient(180deg, rgba(22, 163, 74, 0.28), rgba(22, 163, 74, 0.08)); }
.cc-banner-sword { background: linear-gradient(180deg, rgba(239, 68, 68, 0.26), rgba(239, 68, 68, 0.08)); }
.cc-banner-guild { background: linear-gradient(180deg, rgba(249, 115, 22, 0.28), rgba(249, 115, 22, 0.08)); }
.cc-banner-peasant { background: linear-gradient(180deg, rgba(250, 204, 21, 0.36), rgba(250, 204, 21, 0.1)); }

.cc-char-art {
  width: 60px;
  height: 56px;
  flex: 0 0 60px;
  background-image: url("/assets/cc_portraits.png?v=11");
  background-size: 1000% 800%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.45));
}

.cc-art-zone .cc-sh-col {
  flex-direction: column;
  gap: 2px;
}

@media (max-width: 480px) {
  .cc-wrap {
    --cc-card-w: clamp(74px, calc((100vw - 104px) / 3), 118px);
  }
  .cc-market-area {
    grid-template-columns: 1fr 30px;
    gap: 4px;
  }
  .cc-market-row {
    grid-template-columns: 32px repeat(3, var(--cc-card-w));
    gap: 4px;
    padding: 4px;
  }
  .cc-real-card {
    min-height: 136px;
  }
  .cc-name-pill {
    margin: 0;
    padding: 3px 3px;
    font-size: 9.5px;
  }
  .cc-art-zone {
    padding: 3px 3px;
    gap: 2px;
  }
  .cc-char-art {
    width: 42px;
    height: 40px;
    flex: 0 0 42px;
    border-radius: 8px;
  }
}

/* Medieval Parchment Scroll Card Header */
.cc-name-pill {
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 38' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23fff8e4'/%3E%3Cstop offset='65%25' stop-color='%23f6e2b3'/%3E%3Cstop offset='100%25' stop-color='%23dfc082'/%3E%3C/linearGradient%3E%3ClinearGradient id='r' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0%25' stop-color='%23d4ae6a'/%3E%3Cstop offset='45%25' stop-color='%23fff6da'/%3E%3Cstop offset='100%25' stop-color='%23c59952'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M16 9 Q90 1 164 9 L160 32 Q90 25 20 32 Z' fill='url(%23g)' stroke='%238c6239' stroke-width='1.4'/%3E%3Cpath d='M7 6 Q13 2 18 7 L21 31 Q15 36 10 31 Z' fill='url(%23r)' stroke='%238c6239' stroke-width='1.3'/%3E%3Cpath d='M173 6 Q167 2 162 7 L159 31 Q165 36 170 31 Z' fill='url(%23r)' stroke='%238c6239' stroke-width='1.3'/%3E%3Cpath d='M12 31 Q17 37 22 32 L20 27' fill='%23b58742' stroke='%237c5329' stroke-width='1'/%3E%3Cpath d='M168 31 Q163 37 158 32 L160 27' fill='%23b58742' stroke='%237c5329' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: #111827;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: 11.5px;
  padding: 5px 14px 7px;
  margin: 2px 2px 0;
  border-radius: 0;
  filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.28));
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

@media (max-width: 480px) {
  .cc-name-pill {
    font-size: 9.5px;
    padding: 4px 10px 6px;
    margin: 2px 1px 0;
  }
}

/* Wood / Stone Card Textures + Hanging Split Heraldic Banner + Sticker Cutout */
.cc-theme-village {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(180, 125, 65, 0.09) 0px,
      rgba(180, 125, 65, 0.09) 18px,
      rgba(255, 245, 225, 0.07) 18px,
      rgba(255, 245, 225, 0.07) 36px
    ),
    linear-gradient(180deg, #f3dcba 0%, #e1be8d 100%);
  border-color: #9a6328;
}

.cc-theme-castle {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(71, 85, 105, 0.06) 0px,
      rgba(71, 85, 105, 0.06) 24px,
      rgba(255, 255, 255, 0.08) 24px,
      rgba(255, 255, 255, 0.08) 48px
    ),
    linear-gradient(180deg, #e5ebf1 0%, #cdd7e3 100%);
  border-color: #64748b;
}

.cc-art-zone {
  position: relative;
  min-height: 70px;
  padding: 6px 4px 5px;
  border-bottom: none;
  background: transparent;
  overflow: hidden;
}

.cc-hang-banner {
  position: absolute;
  top: 0;
  bottom: 2px;
  left: 13%;
  right: 13%;
  z-index: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.cc-hang-rod {
  height: 3px;
  margin: 0 -4px;
  background: linear-gradient(180deg, #92400e, #451a03);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.cc-hang-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 0 3px;
  height: 5px;
}

.cc-hang-tabs span:nth-child(1),
.cc-hang-tabs span:nth-child(2) {
  background: var(--b1);
}

.cc-hang-tabs span:nth-child(3),
.cc-hang-tabs span:nth-child(4) {
  background: var(--b2);
}

.cc-hang-cloth {
  flex: 1;
  background: linear-gradient(90deg, var(--b1) 0 50%, var(--b2) 50% 100%);
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.12);
  clip-path: polygon(
    0 0, 100% 0,
    100% 88%, 92% 96%, 85% 86%, 76% 98%, 64% 90%,
    50% 97%, 38% 88%, 26% 99%, 15% 87%, 7% 95%, 0 86%
  );
}

.cc-art-zone .cc-coin-col,
.cc-art-zone .cc-sh-col,
.cc-art-zone .cc-char-art {
  position: relative;
  z-index: 1;
}

.cc-msg-arrow {
  width: 21px;
  height: 21px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.cc-char-art {
  width: 64px;
  height: 60px;
  flex: 0 0 64px;
  filter:
    drop-shadow(1px 0 0 #fff)
    drop-shadow(-1px 0 0 #fff)
    drop-shadow(0 1px 0 #fff)
    drop-shadow(0 -1px 0 #fff)
    drop-shadow(0 3px 3px rgba(15, 23, 42, 0.38));
}

@media (max-width: 480px) {
  .cc-art-zone {
    min-height: 54px;
    padding: 4px 2px 3px;
  }
  .cc-char-art {
    width: 46px;
    height: 44px;
    flex: 0 0 46px;
  }
  .cc-msg-arrow {
    width: 17px;
    height: 17px;
    font-size: 9px;
    border-radius: 4px;
  }
}

/* Co-op Minesweeper & Co-op Sudoku */
.ms-wrap,
.sdk-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ms-grid {
  display: grid;
  gap: 3px;
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
}

.ms-cell {
  aspect-ratio: 1;
  background: linear-gradient(145deg, #273552, #1b263d);
  border: 1.5px solid #384c73;
  border-radius: 6px;
  color: var(--text);
  font-weight: 900;
  font-size: 14px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.ms-cell.revealed {
  background: #0f172a;
  border-color: #1e293b;
  cursor: default;
}

.ms-cell.flagged {
  background: rgba(234, 179, 8, 0.16);
  border-color: var(--gold);
}

.ms-cell.exploded {
  background: rgba(244, 63, 94, 0.35);
  border-color: var(--red);
}

.ms-cell.mine {
  background: rgba(148, 163, 184, 0.2);
}

.ms-n1 { color: #38bdf8; }
.ms-n2 { color: #4ade80; }
.ms-n3 { color: #f87171; }
.ms-n4 { color: #c084fc; }
.ms-n5 { color: #fbbf24; }
.ms-n6 { color: #2dd4bf; }
.ms-n7 { color: #f472b6; }
.ms-n8 { color: #e2e8f0; }

.sdk-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  width: 100%;
  max-width: 396px;
  margin: 0 auto;
  border: 2.5px solid #64748b;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
}

.sdk-cell {
  aspect-ratio: 1;
  background: #131c31;
  border: 0.5px solid #263450;
  color: #38bdf8;
  font-size: 17px;
  font-weight: 800;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  position: relative;
}

.sdk-cell.b-right {
  border-right: 2.5px solid #64748b;
}

.sdk-cell.b-bottom {
  border-bottom: 2.5px solid #64748b;
}

.sdk-cell.fixed {
  color: #f8fafc;
  background: #18233a;
}

.sdk-cell.peer {
  background: #1d2b47;
}

.sdk-cell.same-val {
  background: rgba(234, 179, 8, 0.22);
}

.sdk-cell.selected {
  background: rgba(56, 189, 248, 0.28);
  box-shadow: inset 0 0 0 2px #38bdf8;
}

.sdk-cell.last-move {
  box-shadow: inset 0 0 0 1.5px var(--gold);
}

.sdk-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
  font-size: 8.5px;
  font-weight: 600;
  color: #94a3b8;
  line-height: 1;
}

.sdk-notes span {
  display: grid;
  place-items: center;
}

.sdk-tools {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.sdk-numpad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}

.sdk-num-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 7px 2px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.1;
}

.sdk-num-btn small {
  font-size: 9px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.sdk-num-btn.done {
  opacity: 0.35;
}

.coop-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.coop-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

.coop-stat-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Minesweeper Duel Scoreboard & Colored Player Mines */
.ms-duel-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ms-duel-player {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 11px;
  padding: 8px 10px;
  text-align: center;
}

.ms-duel-player.ms-p0.is-turn {
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.ms-duel-player.ms-p1.is-turn {
  border-color: #f43f5e;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.3);
}

.ms-dp-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-dp-score {
  font-size: 16px;
  font-weight: 900;
  margin-top: 2px;
}

.ms-cell.ms-mine-p0 {
  background: rgba(2, 132, 199, 0.35);
  border-color: #38bdf8;
  box-shadow: inset 0 0 0 1px #38bdf8;
}

.ms-cell.ms-mine-p1 {
  background: rgba(225, 29, 72, 0.35);
  border-color: #f43f5e;
  box-shadow: inset 0 0 0 1px #f43f5e;
}

.ms-cell.last-cell {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* Regicide · Marvel Arena & Dynamic Boss Gauges */
.reg-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reg-boss-track {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
}

.reg-bdot {
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  padding: 2px 0;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.reg-bdot.done {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--green);
  color: #86efac;
  text-decoration: line-through;
}

.reg-bdot.now {
  background: rgba(244, 63, 94, 0.25);
  border-color: var(--red);
  color: #fda4af;
}

.reg-boss-arena {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 10px;
  background: linear-gradient(155deg, #1d1b36 0%, #111827 100%);
  border: 1.5px solid #4c1d95;
  border-radius: 13px;
  padding: 10px;
  align-items: center;
}

.reg-boss-art {
  width: 98px;
  height: 132px;
  border-radius: 9px;
  background-image: url("/assets/regicide_marvel.jpg?v=19");
  background-size: 900% 600%;
  background-repeat: no-repeat;
  border: 2px solid #f43f5e;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.reg-tier-tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  text-align: center;
  background: rgba(15, 23, 42, 0.85);
  color: #fde047;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 0;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

.reg-boss-info {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.reg-boss-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 16px;
  font-weight: 800;
}

.reg-imm-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.16);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

.reg-imm-badge.canceled {
  background: rgba(192, 132, 252, 0.18);
  border-color: #c084fc;
  color: #e9d5ff;
}

.reg-gauge-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reg-gauge-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.reg-gauge-head b {
  color: var(--text);
}

.reg-exact-txt {
  color: #4ade80 !important;
}

.reg-prev-txt {
  color: #fde047 !important;
}

.reg-sh-txt {
  color: #38bdf8;
}

.reg-sh-prev {
  color: #7dd3fc !important;
}

.reg-bar-bg {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #0b1120;
  border: 1px solid #334155;
  overflow: hidden;
}

.reg-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.reg-bar-fill.hp-high { background: linear-gradient(90deg, #16a34a, #4ade80); }
.reg-bar-fill.hp-mid { background: linear-gradient(90deg, #d97706, #facc15); }
.reg-bar-fill.hp-low { background: linear-gradient(90deg, #b91c1c, #f43f5e); }

.reg-bar-preview {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(250, 204, 21, 0.85) 0 4px,
    rgba(244, 63, 94, 0.85) 4px 8px
  );
  animation: pulseFade 1s ease-in-out infinite;
}

.reg-bar-atk {
  height: 100%;
  background: linear-gradient(90deg, #dc2626, #fb923c);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.reg-bar-shield {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.reg-turn-pill {
  border-color: var(--green);
  color: #86efac;
}

.reg-hand-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.reg-hand-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.reg-card {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 9px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.reg-card:disabled {
  cursor: default;
  opacity: 0.72;
}

.reg-card.selected {
  border-color: #facc15;
  transform: translateY(-5px);
  box-shadow: 0 6px 14px rgba(250, 204, 21, 0.35);
}

.reg-card-art {
  width: 100%;
  aspect-ratio: 104 / 140;
  background-image: url("/assets/regicide_marvel.jpg?v=19");
  background-size: 900% 600%;
  background-repeat: no-repeat;
  position: relative;
}

.reg-card-val {
  position: absolute;
  top: 3px;
  left: 3px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 6px;
  border: 1.5px solid #fff;
}

.reg-card-name {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reg-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.reg-help-p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: #cbd5e1;
}

/* Solid Dark Top-Left Corner Badge Covering Original Card Stats */
.reg-boss-art,
.reg-card-art {
  background-image: url("/assets/regicide_marvel.jpg?v=20");
}

.reg-card-art {
  aspect-ratio: 220 / 300;
}

.reg-card-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 26%;
  min-width: 24px;
  height: 36%;
  min-height: 40px;
  background: #080b12;
  border-right: 1.5px solid #475569;
  border-bottom: 1.5px solid #475569;
  border-bottom-right-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px 1px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.55);
}

.reg-cc-rank {
  color: #f8fafc;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.reg-cc-suit {
  display: grid;
  place-items: center;
  line-height: 1;
}

.reg-x2-sym {
  font-size: 12px;
  font-weight: 900;
  color: #fb7185;
  letter-spacing: -0.03em;
}

.reg-boss-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 30%;
  min-width: 29px;
  height: 44%;
  background: #080b12;
  border-right: 1.5px solid #f43f5e;
  border-bottom: 1.5px solid #f43f5e;
  border-bottom-right-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.6);
}

.reg-bc-atk {
  font-size: 10px;
  font-weight: 900;
  color: #fb923c;
  line-height: 1;
}

.reg-bc-hp {
  font-size: 10px;
  font-weight: 900;
  color: #4ade80;
  line-height: 1;
}

.reg-bc-suit {
  display: grid;
  place-items: center;
  margin-top: 1px;
}

/* Studio High-Res Castle Combo Sprites (Shields, Banners, Characters) */
.cc-sh-img {
  background-image: url("/assets/cc_shields.png?v=21");
  background-size: 600% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.35));
}

.cc-art-zone {
  min-height: 82px;
  padding: 5px 4px 4px;
}

.cc-banner-img {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 82px;
  height: 82px;
  background-image: url("/assets/cc_banners.png?v=21");
  background-size: 600% 400%;
  background-repeat: no-repeat;
  z-index: 0;
  pointer-events: none;
  opacity: 0.94;
}

.cc-char-art {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  background-image: url("/assets/cc_chars.png?v=38");
  background-size: 1000% 800%;
  background-repeat: no-repeat;
  filter:
    drop-shadow(1px 0 0 #fff)
    drop-shadow(-1px 0 0 #fff)
    drop-shadow(0 1px 0 #fff)
    drop-shadow(0 -1px 0 #fff)
    drop-shadow(0 3px 3px rgba(15, 23, 42, 0.35));
}

@media (max-width: 480px) {
  .cc-art-zone {
    min-height: 62px;
    padding: 3px 2px;
  }
  .cc-banner-img {
    width: 62px;
    height: 62px;
  }
  .cc-char-art {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
  }
  .cc-sh-col .cc-sh-img {
    width: 19px !important;
    height: 19px !important;
  }
}

/* Fix Card Layout: Visible Corner Shields, Centered Lower Character, Full Unclipped Name */
.cc-name-pill {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.05;
  font-size: 10.5px;
  padding: 5px 11px 7px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cc-art-zone {
  position: relative;
  display: block;
  height: 88px;
  min-height: 88px;
  padding: 0;
  overflow: visible;
}

.cc-art-zone .cc-coin-col {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 3;
}

.cc-art-zone .cc-sh-col {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  flex-direction: column;
  gap: 2px;
}

.cc-banner-img {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 78px;
  height: 78px;
  z-index: 1;
}

.cc-char-art {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  z-index: 2;
}

@media (max-width: 480px) {
  .cc-name-pill {
    font-size: 8.8px;
    padding: 4px 8px 5px;
    min-height: 20px;
  }
  .cc-art-zone {
    height: 68px;
    min-height: 68px;
  }
  .cc-banner-img {
    width: 60px;
    height: 60px;
  }
  .cc-char-art {
    width: 56px;
    height: 56px;
  }
}

/* Fine-Tune Card Proportions to Match Original Castle Combo Layout (Photo 2) */
.cc-art-zone {
  height: 102px;
  min-height: 102px;
  margin-bottom: 4px;
}

.cc-banner-img {
  top: -2px;
  width: 96px;
  height: 94px;
}

.cc-char-art {
  bottom: -4px;
  width: 82px;
  height: 82px;
}

.cc-body {
  padding: 2px 5px 5px;
  gap: 4px;
}

@media (max-width: 480px) {
  .cc-art-zone {
    height: 78px;
    min-height: 78px;
    margin-bottom: 3px;
  }
  .cc-banner-img {
    top: -2px;
    width: 74px;
    height: 72px;
  }
  .cc-char-art {
    bottom: -3px;
    width: 64px;
    height: 64px;
  }
}

/* Studio Symbols Sprite Sheet + Authentic Scoring Scroll (Bombardier Style) */
.cc-sym-img {
  background-image: url("/assets/cc_symbols.png?v=24");
  background-size: 800% 700%;
  background-repeat: no-repeat;
}

.cc-coin-sym,
.cc-seal-sym,
.cc-card-val-wrap,
.cc-missing-wrap {
  position: relative;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
}

.cc-coin-sym b {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  color: #1c1917;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.cc-coin-top .cc-coin-sym b {
  font-size: 13px;
}

.cc-coin-top.cant-afford {
  filter: hue-rotate(-40deg) saturate(1.4);
}

.cc-coin-top.discounted {
  filter: hue-rotate(75deg) saturate(1.2);
}

.cc-seal-sym b {
  position: absolute;
  color: #fff;
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.cc-card-val-wrap b,
.cc-missing-wrap b {
  position: absolute;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.cc-missing-wrap b {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.cc-arrow-wrap {
  position: relative;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
}

.cc-arrow-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.cc-msg-img {
  display: grid;
  place-items: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* Authentic Rolled Parchment Scoring Scroll at Bottom of Card */
.cc-scroll {
  background: transparent;
  background-image: url("/assets/cc_scroll.png?v=24");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: none;
  border-radius: 0;
  padding: 6px 12px;
  min-height: 36px;
  font-size: 11px;
  font-weight: 800;
  color: #450a0a;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.25));
}

@media (max-width: 480px) {
  .cc-scroll {
    padding: 4px 8px;
    min-height: 28px;
    font-size: 9.5px;
  }
  .cc-coin-top .cc-coin-sym {
    width: 22px !important;
    height: 22px !important;
  }
  .cc-coin-top .cc-coin-sym .cc-sym-img {
    width: 22px !important;
    height: 22px !important;
  }
}

/* Uniform Fixed Card Proportions & Single-Line Fixed-Height Scoring Scroll */
.cc-real-card {
  height: 214px;
  min-height: 214px;
  max-height: 214px;
}

.cc-name-pill {
  height: 26px;
  min-height: 26px;
  max-height: 26px;
  padding: 3px 10px 5px;
  font-size: 10px;
}

.cc-art-zone {
  height: 98px;
  min-height: 98px;
  margin-bottom: 0;
}

.cc-body {
  flex: 1;
  padding: 2px 4px 4px;
  gap: 2px;
  justify-content: space-between;
}

.cc-instant {
  flex: 1;
  min-height: 0;
  font-size: 10px;
  line-height: 1.15;
  align-content: center;
}

.cc-scroll {
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 2px 9px;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 3px;
  font-size: 10px;
  overflow: hidden;
}

.cc-scroll .cc-seal-sym,
.cc-scroll .cc-seal-sym .cc-sym-img {
  width: 23px !important;
  height: 23px !important;
}

.cc-scroll .cc-sh-img,
.cc-scroll .cc-sym-img {
  max-width: 24px;
  max-height: 24px;
}

.cc-scroll .cc-arrow-wrap {
  transform: scale(0.96);
  margin: -1px;
}

@media (max-width: 480px) {
  .cc-wrap {
    --cc-card-w: clamp(74px, calc((100vw - 104px) / 3), 118px);
  }
  .cc-market-area {
    grid-template-columns: 1fr 30px;
    gap: 4px;
  }
  .cc-market-row {
    grid-template-columns: 32px repeat(3, var(--cc-card-w));
    gap: 4px;
    padding: 4px;
  }
  .cc-real-card {
    height: 174px;
    min-height: 174px;
    max-height: 174px;
  }
  .cc-name-pill {
    height: 22px;
    min-height: 22px;
    max-height: 22px;
    font-size: 8.5px;
    padding: 2px 7px 4px;
  }
  .cc-art-zone {
    height: 74px;
    min-height: 74px;
  }
  .cc-instant {
    font-size: 8.8px;
  }
  .cc-scroll {
    height: 30px;
    min-height: 30px;
    max-height: 30px;
    padding: 2px 6px;
    gap: 2px;
    font-size: 8.8px;
  }
  .cc-scroll .cc-seal-sym,
  .cc-scroll .cc-seal-sym .cc-sym-img {
    width: 18px !important;
    height: 18px !important;
  }
  .cc-scroll .cc-sh-img,
  .cc-scroll .cc-sym-img {
    max-width: 16px;
    max-height: 16px;
  }
}

/* Original Side Vertical Name Ribbon, Lower Character & Richer Aged Parchment Scroll */
.cc-card-slot {
  width: calc(148px * var(--cc-scale, 1));
  height: calc(198px * var(--cc-scale, 1));
  position: relative;
  flex-shrink: 0;
}

.cc-real-card {
  width: 148px;
  min-width: 148px;
  max-width: 148px;
  height: 198px;
  min-height: 198px;
  max-height: 198px;
  transform: scale(var(--cc-scale, 1));
  transform-origin: top left;
}

.cc-place-slot {
  width: 148px;
  height: 198px;
  transform: scale(var(--cc-scale, 1));
  transform-origin: top left;
}

.cc-dyn-compact {
  --cc-scale: 0.62;
}

.cc-art-zone {
  height: 108px;
  min-height: 108px;
  margin-bottom: 2px;
}

.cc-banner-img {
  top: 2px;
  width: 122px;
  height: 96px;
}

.cc-char-art {
  bottom: -10px;
  width: 96px;
  height: 96px;
}

.cc-art-zone .cc-coin-col {
  top: 2px;
  left: 2px;
  gap: 0;
  z-index: 4;
}

.cc-art-zone .cc-sh-col {
  top: 8px;
  right: 3px;
}

.cc-coin-top {
  position: relative;
  z-index: 4;
}

.cc-coin-top .cc-coin-sym b {
  font-size: 16.5px;
}

.cc-msg-img {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: -8px;
  flex-shrink: 0;
  overflow: visible;
}

.cc-msg-img .cc-sym-img {
  flex-shrink: 0;
  width: 27px !important;
  height: 27px !important;
}

.cc-side-ribbon {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 86px;
  margin-top: -15px;
  padding: 13px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 1px 1.5px rgba(15, 23, 42, 0.28));
}

.cc-side-ribbon.has-arrow {
  padding: 7px 0 8px;
  justify-content: flex-start;
}

.cc-ribbon-castle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 100' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='s' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0%25' stop-color='%238c9eb2'/%3E%3Cstop offset='42%25' stop-color='%23dce5ee'/%3E%3Cstop offset='100%25' stop-color='%23798ca2'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M1 0 H21 V98 L11 88 L1 98 Z' fill='url(%23s)' stroke='%23334155' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E");
  color: #0f172a;
}

.cc-ribbon-village {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 100' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='b' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0%25' stop-color='%23a6723c'/%3E%3Cstop offset='42%25' stop-color='%23e5be8a'/%3E%3Cstop offset='100%25' stop-color='%238c5a28'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M1 0 H21 V98 L11 88 L1 98 Z' fill='url(%23b)' stroke='%234a2c0f' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E");
  color: #1c1005;
}

.cc-side-ribbon span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  max-height: 65px;
  letter-spacing: 0.01em;
}

.cc-side-ribbon.cc-name-long span {
  font-size: 8.8px;
  letter-spacing: -0.02em;
  max-height: 66px;
}

.cc-side-ribbon.has-arrow span {
  font-size: 10.8px;
  max-height: 50px;
  margin: auto 0;
}

.cc-side-ribbon.has-arrow.cc-name-long span {
  font-size: 7.4px;
  letter-spacing: -0.03em;
  max-height: 51px;
}

.cc-instant {
  padding-left: 0;
  justify-content: center;
  text-align: center;
  font-size: 10.8px;
  line-height: 1.05;
  gap: 2px 3px;
}

.cc-keys-group {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  flex-wrap: nowrap;
  gap: 0;
}

.cc-instant .cc-coin-sym,
.cc-instant .cc-sh-img,
.cc-instant .cc-sym-img:not(.cc-coin-sym .cc-sym-img) {
  transform: scale(1.14);
  margin: 0 2px;
}

.cc-keys-group .cc-sym-img,
.cc-instant .cc-keys-group .cc-sym-img {
  margin: 0 -2px;
}

.cc-pick-modes .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

/* Richer Aged Medieval Parchment Scroll at Bottom */
.cc-scroll {
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 46' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='p' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23fffbeb'/%3E%3Cstop offset='55%25' stop-color='%23f7e5b7'/%3E%3Cstop offset='100%25' stop-color='%23dfbe7d'/%3E%3C/linearGradient%3E%3ClinearGradient id='c' x1='0' y1='0' x2='1' y2='0'%3E%3Cstop offset='0%25' stop-color='%23b5843f'/%3E%3Cstop offset='40%25' stop-color='%23fff4d4'/%3E%3Cstop offset='100%25' stop-color='%239b6d2d'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M16 6 Q110 3 204 6 L204 40 Q110 43 16 40 Z' fill='url(%23p)' stroke='%23784c1d' stroke-width='1.5'/%3E%3Crect x='3' y='3' width='14' height='40' rx='6' fill='url(%23c)' stroke='%236b4218' stroke-width='1.5'/%3E%3Crect x='203' y='3' width='14' height='40' rx='6' fill='url(%23c)' stroke='%236b4218' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  padding: 2px 14px;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.32));
}

/* Disable legacy mobile pixel overrides inside .cc-real-card because zoom: var(--cc-scale) scales the canonical 148x198 card proportionally */
@media (max-width: 480px) {
  .cc-market-area {
    grid-template-columns: 1fr 30px;
    gap: 4px;
  }
  .cc-market-row {
    grid-template-columns: 32px repeat(3, calc(148px * var(--cc-scale, 1)));
    gap: 4px;
    padding: 4px;
  }
  .cc-dyn-compact {
    --cc-scale: 0.52;
  }
}

.cn-stat-sq {
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
}

/* Detailed Card Dialog & PDF-Style 78-Card Roster in Help */
.cc-board-clickable {
  cursor: pointer;
}

.cc-card-modal {
  width: min(92vw, 380px);
}

.cc-card-dlg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 13px;
}

.cc-card-dlg-sec {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.cc-quick-rules {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}

.cc-quick-rules li {
  margin-bottom: 4px;
}

.cc-roster-search {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 8px;
}

.cc-roster-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 2px;
}

.cc-roster-item {
  border-radius: 9px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.35;
}

.cc-roster-castle {
  background: rgba(148, 163, 184, 0.12);
  border-left: 3px solid #94a3b8;
}

.cc-roster-village {
  background: rgba(217, 119, 6, 0.12);
  border-left: 3px solid #d97706;
}

.cc-roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.cc-roster-name {
  font-weight: 800;
  font-size: 13px;
  color: #f8fafc;
}

.cc-roster-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.cc-roster-txt {
  color: #e2e8f0;
  margin-top: 2px;
}

/* Original Castle Combo Card Back from Photo for Placed Face-Down Cards */
.cc-placed-back {
  position: relative;
  overflow: hidden;
  padding: 7px 4px 8px;
  justify-content: space-between;
  align-items: center;
  background-image: url("/assets/cc_backs.jpg?v=41");
  background-size: 200% 100%;
  background-repeat: no-repeat;
}

.cc-back-ribbon {
  position: relative;
  z-index: 2;
  width: 96%;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 0 10px 3px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
}

.cc-placed-back-castle .cc-back-ribbon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 34' preserveAspectRatio='none'%3E%3Cpath d='M3 9 Q70 0 137 9 L129 19 L137 29 Q70 20 3 29 L11 19 Z' fill='%234b5563' stroke='%231f2937' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M8 11 Q70 3 132 11 L126 19 L132 27 Q70 19 8 27 L14 19 Z' fill='none' stroke='%23e5e7eb' stroke-width='0.9' opacity='0.85'/%3E%3C/svg%3E");
}

.cc-placed-back-village .cc-back-ribbon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 34' preserveAspectRatio='none'%3E%3Cpath d='M3 9 Q70 0 137 9 L129 19 L137 29 Q70 20 3 29 L11 19 Z' fill='%237c4a1e' stroke='%23451a03' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M8 11 Q70 3 132 11 L126 19 L132 27 Q70 19 8 27 L14 19 Z' fill='none' stroke='%23fef3c7' stroke-width='0.9' opacity='0.85'/%3E%3C/svg%3E");
}

.cc-back-ribbon .cc-back-pill {
  display: inline-flex;
  align-items: center;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}

.cc-back-ribbon .cc-back-plus {
  font-size: 15px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.cc-back-sub {
  position: relative;
  z-index: 2;
  width: 82%;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 28' preserveAspectRatio='none'%3E%3Cpath d='M3 7 Q60 1 117 7 L110 15 L117 23 Q60 17 3 23 L10 15 Z' fill='%23ffffff' stroke='%23475569' stroke-width='1.4' stroke-linejoin='round'/%3E%3Cpath d='M8 9 Q60 4 112 9 L107 15 L112 21 Q60 16 8 21 L13 15 Z' fill='none' stroke='%23cbd5e1' stroke-width='0.8'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: #1e293b;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  font-size: 11.5px;
  font-weight: 800;
  padding-bottom: 1px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

.cc-placed-back-castle {
  background-position: 0% 0%;
  border-color: #64748b;
}

.cc-placed-back-village {
  background-position: 100% 0%;
  border-color: #a16207;
}

/* Lobby Tabs, Collapsible Finished Games, Mini-Chat, Friends & Stats */
.lobby-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.lobby-tab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.lobby-tab.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--accent);
  color: var(--text);
}

.tab-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.finished-collapse {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
}

.finished-collapse summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 2px 0;
}

.finished-collapse[open] summary {
  margin-bottom: 8px;
  color: var(--text);
}

.room-start-banner {
  margin-bottom: 10px;
}

.room-chat-mini {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  margin-bottom: 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
}

.rcm-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.my-id-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}

.friend-info {
  min-width: 0;
  flex: 1;
}

.friend-name {
  font-weight: 700;
  font-size: 14px;
}

.friend-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-acts {
  display: flex;
  gap: 5px;
}

.dm-box {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px;
  margin-top: 8px;
}

.dm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.dm-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dm-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 8px;
  padding: 2px;
}

.dm-msg {
  align-self: flex-start;
  max-width: 85%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 9px;
  font-size: 13px;
}

.dm-msg.is-me {
  align-self: flex-end;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.4);
}

.dm-msg-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}

.dm-invite-btn {
  margin-top: 5px;
  width: 100%;
}

.dm-form {
  display: flex;
  gap: 6px;
}

.dm-form input {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 8px;
  text-align: center;
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

.stat-lbl {
  font-size: 11px;
  color: var(--muted);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  font-size: 12.5px;
}

.stats-table th,
.stats-table td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.stats-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

/* Codenames: Duet */
.cn-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cn-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.cn-banner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  text-align: center;
}

.cn-banner.is-win {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.14);
}

.cn-banner.is-loss {
  border-color: var(--red);
  background: rgba(244, 63, 94, 0.14);
}

.cn-clue-word {
  color: var(--gold);
  font-size: 15px;
}

.cn-clue-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cn-clue-form input {
  flex: 1 1 auto;
  width: auto;
  min-width: 120px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13.5px;
}

.cn-clue-form select {
  flex: 0 0 60px;
  width: 60px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 6px;
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
}

.cn-clue-form button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.cn-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.cn-tile {
  position: relative;
  min-height: 58px;
  padding: 6px 4px;
  border-radius: 9px;
  border: 2px solid #94a3b8;
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 800;
  font-size: 11px;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  word-break: break-word;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.cn-top-btns {
  display: inline-flex;
  gap: 5px;
}

.cn-tile:disabled {
  cursor: default;
}

.cn-tile.key-green:not(.is-green-found) {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: #22c55e;
  color: #14532d;
}

.cn-tile.key-assassin:not(.is-assassin-hit) {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border-color: #0f172a;
  color: #f8fafc;
}

.cn-tile.is-green-found.is-covered {
  background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
  border-color: #86efac;
  color: #ffffff;
  cursor: pointer;
}

.cn-tile.is-green-found.is-covered .cn-word {
  opacity: 0;
}

.cn-tile.is-green-found.is-covered .cn-cover-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255, 255, 255, 0.85);
}

.cn-tile.is-green-found.is-peeked {
  background: linear-gradient(180deg, #16a34a 0%, #14532d 100%);
  border-color: #86efac;
  color: #ffffff;
  cursor: pointer;
  padding-top: 14px;
}

.cn-tile.is-green-found.is-peeked .cn-cover-cap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 13px;
  background: #22c55e;
  border-bottom: 1px solid #86efac;
  border-radius: 7px 7px 0 0;
  font-size: 8px;
  line-height: 12px;
  color: #052e16;
  font-weight: 900;
}

.cn-bys-sq {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: #94a3b8;
  border: 1.5px solid #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.cn-tile.is-assassin-hit {
  background: #090d16;
  border-color: var(--red);
  color: #fda4af;
}

.cn-agent-tag {
  font-size: 12px;
  line-height: 1;
  margin-bottom: 2px;
}

.cn-bys-corner {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  display: inline-flex;
  gap: 2px;
}

.cn-bys {
  background: #d97706;
  color: #fffbeb;
  border: 1px solid #fff;
  font-size: 9px;
  font-weight: 900;
  padding: 0 4px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.cn-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.cn-history {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.cn-hist-title {
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 2px;
}

@media (max-width: 480px) {
  .cn-tile {
    min-height: 48px;
    font-size: 9.5px;
    padding: 4px 2px;
  }
}
