/* ─── Fonts ────────────────────────────────────── */
@font-face {
  font-family: 'Cobblestone';
  src: url('fonts/Cobblestone.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ─── BLOQUE TEMPORAL: espada dorada ───────────── */
#temp-sword-block {
  display: none;
}

#temp-sword-img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  image-rendering: pixelated;
  /* color oro: filter: grayscale(100%) sepia(100%) saturate(4) hue-rotate(5deg) brightness(1.15); */
  filter: grayscale(100%) sepia(100%);
}

/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Prevent text selection and long-press callout on mobile */
html, body, * {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:          #0f0f1a;
  --bg2:         #1a1a2e;
  --bg3:         #16213e;
  --accent:      #7c3aed;
  --accent-h:    #6d28d9;
  --accent2:     #06b6d4;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --border:      #2d3748;
  --danger:      #ef4444;
  --success:     #22c55e;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  --radius:      12px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ─── Screens ───────────────────────────────────── */
.screen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.screen.hidden { display: none; }

/* ─── Lobby ─────────────────────────────────────── */
.lobby-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: var(--shadow);
}

.logo { font-size: 56px; margin-bottom: 12px; animation: float 3s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 6px; }
.subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 0.95rem; }

.form-group { text-align: left; margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }

input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--text-muted); }

.lobby-buttons { display: flex; flex-direction: column; gap: 12px; }

.btn-clear-session {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: background 0.2s, color 0.2s;
  z-index: 10;
}
.btn-clear-session:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
  border-color: rgba(239,68,68,0.3);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-form { display: flex; gap: 8px; }
.join-form input { flex: 1; letter-spacing: 2px; text-align: center; }

/* ─── Buttons ───────────────────────────────────── */
.btn {
  padding: 11px 22px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 13px;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger-sm { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 6px 14px; font-size: 0.85rem; border-radius: 6px; }
.btn-danger-sm:hover { background: var(--danger); color: #fff; }

.btn-roll {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 1.3rem;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(124,58,237,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-roll:hover:not(:disabled) {
  box-shadow: 0 0 36px rgba(124,58,237,0.6);
  transform: translateY(-2px);
}
.btn-roll:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--border); }

/* ─── Error ─────────────────────────────────────── */
.error-msg {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.15);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 0.9rem;
}
.hidden { display: none !important; }

/* ─── Room Header ───────────────────────────────── */
#room-screen {
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 30;
}

/* ─── Settings button & panel ───────────────────── */
.settings-wrapper {
  position: relative;
}

.btn-settings {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}
.btn-settings:hover {
  background: var(--bg3);
  border-color: var(--accent);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-panel.hidden { display: none; }

.settings-room-code-label {
  display: block;
  text-align: center;
  color: var(--accent2);
  letter-spacing: 3px;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 0;
  border-radius: 6px;
  transition: background 0.15s;
}
.settings-room-code-label:hover {
  background: var(--bg3);
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

.settings-leave {
  width: 100%;
  text-align: center;
}

/* ─── Room Body ─────────────────────────────────── */
.room-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Dice area - now just a placeholder; visual is handled by the fixed canvas */
.dice-area {
  flex: 1;
  position: relative;
  background: transparent;
  min-width: 0;
}
.dice-area--worst {}
.dice-area--best {}

/* diceappgame container — fills the viewport like the old dddice canvas */
#dice-container {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

#dice-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  pointer-events: none;
}

/* Prevent text selection across the whole room while interacting */
#room-screen {
  -webkit-user-select: none;
  user-select: none;
}

.roll-result {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(15,15,26,0.85);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  backdrop-filter: blur(8px);
  animation: fadeSlideIn 0.4s ease;
  transition: border-color 0.3s, box-shadow 0.3s, color 0.3s;
}
.roll-result.result--worst {
  border-color: #ef4444;
  box-shadow: 0 0 18px rgba(239,68,68,0.55);
  color: #fca5a5;
}
.roll-result.result--best {
  border-color: #f59e0b;
  box-shadow: 0 0 22px rgba(245,158,11,0.65);
  color: #fde68a;
  background: rgba(30,20,5,0.9);
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Sidebar (removed — replaced by #players-bar) */

/* ─── Tarot card info — waiting-ready state ────── */
#tarot-card-info.waiting-ready {
  pointer-events: none; /* container never blocks clicks */
}
#tarot-card-info.waiting-ready #tarot-card-info-inner {
  color: #02df1f;
  cursor: pointer;
}

/* ─── Player bookmark tabs ──────────────────────── */
#players-bar {
  position: fixed;
  top: 0;
  left: 16px;
  display: flex;
  flex-direction: row;
  gap: 6px;
  z-index: 35;
  pointer-events: none;
  padding: 0;
}

.player-tab {
  pointer-events: all;
  cursor: pointer;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--bg2);
  border: 2px solid #000;
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  /* collapsed: just the initial circle (36px content + 2px left + 2px right borders) */
  width: 40px;
  transition: width 0.28s cubic-bezier(0.34, 1.2, 0.64, 1), border-color 0.3s, box-shadow 0.3s;
  white-space: nowrap;
  user-select: none;
}
.player-tab.active-turn {
  border-color: #f59e0b;
  border-width: 2px;
  box-shadow: 0 4px 18px rgba(245,158,11,0.5);
}
.player-tab.connecting .player-tab__initial {
  background: #4b5563 !important;
  opacity: 0.7;
}
.player-tab.expanded {
  width: var(--tab-expanded-w, 120px);
}

.player-tab__initial {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 0 0 8px 8px;
  color: #fff;
  text-transform: uppercase;
  background: var(--tab-color, var(--accent));
}

.player-tab__name {
  padding: 0 10px 0 6px;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.18s ease 0.08s;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-tab.expanded .player-tab__name {
  opacity: 1;
}

/* ─── Roll history bar ──────────────────────────── */
.roll-history-bar {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 6px 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  overflow: hidden;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── AC badge (centered over sword, fixed) ──────── */
.ac-badge {
  position: fixed;
  bottom: 180px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 130px;
  pointer-events: none;
}

.ac-badge img {
  height: 180px;
  width: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.ac-value {
  position: absolute;
  top: calc(50% - 22px);
  left: 50%;
  transform: translate(calc(-50% + 1px), -65%);
  font-family: 'Cobblestone', serif;
  font-size: 2.3rem;
  font-weight: 700;
  color: #ddddddc0;
  -webkit-text-stroke: 3px rgba(0,0,0,0.95);
  paint-order: stroke fill;
  text-shadow:
    2px 0 0 rgba(40,40,40,0.95), -2px 0 0 rgba(40,40,40,0.95), 0 2px 0 rgba(40,40,40,0.95), 0 -2px 0 rgba(40,40,40,0.95),
    2px 2px 0 rgba(40,40,40,0.95), -2px -2px 0 rgba(40,40,40,0.95), 2px -2px 0 rgba(40,40,40,0.95), -2px 2px 0 rgba(40,40,40,0.95),
    0 0 10px rgba(40,40,40,0.95), 0 0 18px rgba(40,40,40,0.95), 0 0 30px rgba(40,40,40,0.95);
  filter: url(#ac-text-inner);
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

#roll-log {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  gap: 0;
  overflow: hidden;
  flex: 1;
}

.roll-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  line-height: 1;
  transition: opacity 0.3s;
}

/* Most recent group is fully visible; older ones fade out */
.roll-group:nth-child(1)  { opacity: 1; }
.roll-group:nth-child(2)  { opacity: 0.55; }
.roll-group:nth-child(3)  { opacity: 0.35; }
.roll-group:nth-child(4)  { opacity: 0.2; }
.roll-group:nth-child(n+5){ opacity: 0.1; }

/* d8 PNG log icon */
.d8-icon { display: block; width: 23px; height: auto; image-rendering: pixelated; }

.d8-icon.worst { filter: brightness(0) saturate(100%) invert(35%) sepia(86%) saturate(3083%) hue-rotate(332deg) brightness(97%) contrast(90%); }

.d8-icon.best  { filter: brightness(0) saturate(100%) invert(79%) sepia(58%) saturate(736%) hue-rotate(348deg) brightness(98%) contrast(96%); }

/* ─── Room Footer ───────────────────────────────── */
/* ─── Turn indicator ────────────────────────────── */
.turn-indicator {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.turn-indicator strong {
  display: block;
  font-size: 0.9rem;
  color: var(--accent2);
}
.turn-indicator.is-my-turn strong {
  color: var(--success);
}

/* ─── Next-turn button ──────────────────────────── */
.btn-next-turn {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
  padding: 0;
}
.btn-next-turn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
}
.btn-next-turn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* dim roll log & card when it's not my turn */
.not-my-turn .roll-history-bar {
  opacity: 0.45;
  pointer-events: none;
}
.not-my-turn .card-drop-zone {
  pointer-events: none;
  opacity: 0.45;
}
.not-my-turn #card-slot-hole {
  pointer-events: none;
}


/* ─── Dice type selector ────────────────────────── */
.dice-selector {
  display: flex;
  gap: 6px;
}

.btn-dice-type {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 8px;
  letter-spacing: 1px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn-dice-type:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}
.btn-dice-type.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124,58,237,0.5);
}

.dice-tag {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  vertical-align: middle;
  text-transform: uppercase;
}

/* Individual die items — draggable */
.die-item {
  display: inline-flex;
  align-items: center;
  cursor: grab;
  border-radius: 8px;
  padding: 0;
  transition: opacity 0.2s;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.die-item:hover {
  opacity: 1;
}
.die-item:active {
  cursor: grabbing;
}
.die-item.dragging {
  opacity: 0.3;
}
.die-item.slotted  { display: none; }

/* ─── Card Drop Zone ────────────────────────────── */
.card-drop-zone {
  position: fixed;
  bottom: 250px;
  right: calc(16.667% - 54px);
  z-index: 22;
  pointer-events: none;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.7));
}

.card-drop-zone--left {
  right: auto;
  left: calc(16.667% - 54px);
}

.card-inner {
  width: 108px;
  height: 152px;
  background: linear-gradient(160deg, #1b1733 0%, #0f1428 55%, #1a1040 100%);
  border: 1.5px solid rgba(124,58,237,0.45);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 2px 8px rgba(0,0,0,0.6),
    0 0 28px rgba(124,58,237,0.12);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* subtle diagonal line pattern on the card body */
.card-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(255,255,255,0.02) 8px,
    rgba(255,255,255,0.02) 9px
  );
  border-radius: 14px;
  pointer-events: none;
}

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.card-corner--tl { top: 7px;    left: 9px; }
.card-corner--br { bottom: 7px; right: 9px; transform: rotate(180deg); }

.card-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0;
}
.card-suit {
  font-size: 0.75rem;
  color: var(--accent2);
}

/* ── The hole / slot ──── */
.card-slot-hole {
  pointer-events: all;   /* drop target */
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background-color: rgba(0,0,0,0.45);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='28' fill='none' stroke='rgba(124,58,237,0.55)' stroke-width='2' stroke-dasharray='4 4' shape-rendering='crispEdges'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  position: relative;
  z-index: 1;
}

.card-slot-hole.drag-over {
  border: 2px solid var(--accent2);
  background-color: rgba(6,182,212,0.15);
  background-image: none;
  box-shadow: 0 0 18px rgba(6,182,212,0.45);
}

.card-slot-hint {
  pointer-events: none;
  user-select: none;
  opacity: 0.3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-slot-hole.has-dice .card-slot-hint { display: none; }

.card-slot-hole.has-dice {
  border: 2px solid rgba(124,58,237,0.7);
  background-color: rgba(0,0,0,0.25);
  background-image: none;
  cursor: pointer;
}
.card-slot-hole.has-dice:hover {
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(239,68,68,0.35);
}

/* ─── Weapon stats group (above sword + shield) ─── */
.weapon-stats-group {
  position: fixed;
  bottom: 368px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.weapon-stats-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.weapon-stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: rgba(15, 10, 30, 0.72);
  border: 1px solid rgba(124,58,237,0.45);
  border-radius: 8px;
  padding: 4px 10px 4px 8px;
}

.weapon-stat-value {
  font-family: 'Cobblestone', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #e2d9f3;
  line-height: 1;
  -webkit-text-stroke: 1px rgba(0,0,0,0.6);
  paint-order: stroke fill;
  min-width: 2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.weapon-stat-icon {
  color: #c4b5fd;
  display: block;
  flex-shrink: 0;
}

/* ─── Sword container + background ─────────────── */
.sword-container {
  position: fixed;
  bottom: 180px;
  left: 50%;
  transform: translateX(calc(-50% - 0px));
  z-index: 22;
  pointer-events: none;
  width: auto;
}

.sword-bg {
  height: 180px;
  width: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  opacity: 1;
}

/* ─── Sword slot hole ───────────────────────────── */
.sword-slot-hole {
  pointer-events: all;
  position: fixed;
  bottom: 98px;
  left: 50%;
  transform: translateX(calc(-50% - 42px));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Ccircle cx='32' cy='32' r='30' fill='none' stroke='rgba(124,58,237,0.55)' stroke-width='2' stroke-dasharray='4 4' shape-rendering='crispEdges'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  z-index: 23;
}

.sword-slot-hole.drag-over {
  border: 2px solid var(--accent2);
  background-color: rgba(6,182,212,0.12);
  background-image: none;
  box-shadow: 0 0 18px rgba(6,182,212,0.45);
}

.sword-slot-hint {
  pointer-events: none;
  user-select: none;
  opacity: 0.3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sword-slot-hole.has-dice .sword-slot-hint { display: none; }

.sword-slot-hole.has-dice {
  border: 2px solid rgba(124,58,237,0.7);
  background-color: transparent;
  background-image: none;
  cursor: pointer;
}
.sword-slot-hole.has-dice:hover {
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(239,68,68,0.35);
}

.not-my-turn .sword-slot-hole {
  pointer-events: none;
  opacity: 0.45;
}

.not-my-turn #card-slot-hole-left {
  pointer-events: none;
  opacity: 0.45;
}

/* ─── Shield slot hole (mirrors sword slot) ─────── */
.shield-slot-hole {
  pointer-events: all;
  position: fixed;
  bottom: 98px;
  left: 50%;
  transform: translateX(calc(-50% + 42px));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Ccircle cx='32' cy='32' r='30' fill='none' stroke='rgba(124,58,237,0.55)' stroke-width='2' stroke-dasharray='4 4' shape-rendering='crispEdges'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  z-index: 23;
}

.shield-slot-hole.drag-over {
  border: 2px solid var(--accent2);
  background-color: rgba(6,182,212,0.12);
  background-image: none;
  box-shadow: 0 0 18px rgba(6,182,212,0.45);
}

.shield-slot-hint {
  pointer-events: none;
  user-select: none;
  opacity: 0.3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shield-slot-hole.has-dice .shield-slot-hint { display: none; }

.shield-slot-hole.has-dice {
  border: 2px solid rgba(124,58,237,0.7);
  background-color: transparent;
  background-image: none;
  cursor: pointer;
}
.shield-slot-hole.has-dice:hover {
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(239,68,68,0.35);
}

.not-my-turn .shield-slot-hole {
  pointer-events: none;
  opacity: 0.45;
}

/* ─── Tarot Peek (bottom center, top only visible) ── */
#tarot-peek.hidden { display: none !important; }

#tarot-peek {
  position: fixed;
  top: 60%;
  left: 0;
  right: 0;
  transform: translateY(calc(-50% - 50px));
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 22;
  pointer-events: none;
}

.tarot-peek-card {
  width: 110px;
  height: 178px;
  border-radius: 10px;
  overflow: hidden;
  border: none;
  box-shadow: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-mask-image: linear-gradient(to bottom, black 30%, rgba(0,0,0,0.3) 55%, rgba(0,0,0,0) 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 30%, rgba(0,0,0,0.3) 55%, rgba(0,0,0,0) 80%, transparent 100%);
  flex-shrink: 0;
  pointer-events: all;
  cursor: pointer;
}

.tarot-peek-card img:not(.reliq-overlay) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ─── Tarot peek toggle button ──────────────────── */
.btn-tarot-peek {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  padding: 0;
}
.btn-tarot-peek:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
}
.btn-tarot-peek.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(124,58,237,0.55);
}

.btn-tarot-peek-top {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  padding: 0;
}
.btn-tarot-peek-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
}
.btn-tarot-peek-top.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(124,58,237,0.55);
}

/* ─── Tarot footer toggle button ─────────────────── */
.btn-tarot-footer {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  padding: 0;
}
.btn-tarot-footer:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
}
.btn-tarot-footer.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(124,58,237,0.55);
}

/* ─── Tarot peek top row ────────────────────────── */
#tarot-peek-top.hidden { display: none !important; }

#tarot-peek-top {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  z-index: 22;
  pointer-events: none;
}

/* ─── Tarot footer row ───────────────────────────── */
#tarot-peek-footer.hidden { display: none !important; }

#tarot-peek-footer {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 16px 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  z-index: 30;
}

.tarot-peek-card--plain {
  -webkit-mask-image: none !important;
  mask-image: none !important;
  overflow: visible !important;
  position: relative;
}

.tarot-peek-card--plain .card-slot-hole {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.tarot-peek-card--back {
  opacity: 0.1;
}

/* ─── Reliq overlay on top-row cards + in-hand cards ─ */
.reliq-overlay {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 96px;
  object-fit: contain;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 3;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.85));
}

/* ─── Unlocked top-row card: same pixel glow as hand cards ── */
.tarot-peek-card--plain.unlocked {
  outline: 2px solid #c9a227;
  outline-offset: -2px;
  /* Bright initial paint — same as .tarot-card static box-shadow */
  box-shadow:
    inset 0 0 0 1px rgba(201,162,39,0.25),
    3px 0 0 1px #7c3aed, -3px 0 0 1px #7c3aed,
    0 3px 0 1px #7c3aed, 0 -3px 0 1px #7c3aed,
    6px 0 0 0 rgba(168,85,247,0.45), -6px 0 0 0 rgba(168,85,247,0.45),
    0 6px 0 0 rgba(168,85,247,0.45), 0 -6px 0 0 rgba(168,85,247,0.45),
    6px 6px 0 0 rgba(168,85,247,0.2), -6px 6px 0 0 rgba(168,85,247,0.2),
    6px -6px 0 0 rgba(168,85,247,0.2), -6px -6px 0 0 rgba(168,85,247,0.2),
    0 14px 36px rgba(0,0,0,0.85);
  animation: tarot-pixel-glow-top 2.4s ease-in-out infinite;
  cursor: pointer;
}

@keyframes tarot-pixel-glow-top {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px rgba(201,162,39,0.25),
      3px 0 0 1px #7c3aed, -3px 0 0 1px #7c3aed,
      0 3px 0 1px #7c3aed, 0 -3px 0 1px #7c3aed,
      6px 0 0 0 rgba(168,85,247,0.45), -6px 0 0 0 rgba(168,85,247,0.45),
      0 6px 0 0 rgba(168,85,247,0.45), 0 -6px 0 0 rgba(168,85,247,0.45),
      6px 6px 0 0 rgba(168,85,247,0.2), -6px 6px 0 0 rgba(168,85,247,0.2),
      6px -6px 0 0 rgba(168,85,247,0.2), -6px -6px 0 0 rgba(168,85,247,0.2),
      0 14px 36px rgba(0,0,0,0.85);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(201,162,39,0.35),
      3px 0 0 1px rgba(192,38,211,0.9), -3px 0 0 1px rgba(192,38,211,0.9),
      0 3px 0 1px rgba(192,38,211,0.9), 0 -3px 0 1px rgba(192,38,211,0.9),
      6px 0 0 0 rgba(192,38,211,0.45), -6px 0 0 0 rgba(192,38,211,0.45),
      0 6px 0 0 rgba(192,38,211,0.45), 0 -6px 0 0 rgba(192,38,211,0.45),
      6px 6px 0 0 rgba(192,38,211,0.2), -6px 6px 0 0 rgba(192,38,211,0.2),
      6px -6px 0 0 rgba(192,38,211,0.2), -6px -6px 0 0 rgba(192,38,211,0.2),
      9px 0 0 0 rgba(192,38,211,0.08), -9px 0 0 0 rgba(192,38,211,0.08),
      0 9px 0 0 rgba(192,38,211,0.08), 0 -9px 0 0 rgba(192,38,211,0.08),
      0 14px 36px rgba(0,0,0,0.85);
  }
}

/* ─── From-top card in hand: no float, only glow ───── */
.tarot-card--from-top {
  position: relative;
  animation: tarot-pixel-glow 2.4s ease-in-out infinite !important;
  overflow: visible !important;
}
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(124,58,237,0.55);
}

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 640px) {
  .lobby-card { padding: 28px 20px; border-radius: 0; border: none; height: 100%; justify-content: center; display: flex; flex-direction: column; max-width: 100%; }
  .room-body { flex-direction: column; }
  .room-header { padding: 10px 14px; gap: 10px; }
  .btn-roll { width: 38px; height: 38px; font-size: 1.1rem; }
}

/* ─── Tarot toggle button ────────────────────────── */
.btn-tarot {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  padding: 0;
}
.btn-tarot:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
}
.btn-tarot.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(124,58,237,0.55);
}

/* ─── Tarot Hand (hidden by default) ───────────────── */
#tarot-hand.hidden { display: none !important; }

/* ─── Tarot Card Info Box ───────────────────────── */
#tarot-card-info {
  position: fixed;
  left: 0;
  right: 0;
  top: 250px;
  width: 100%;
  z-index: 1002;
  pointer-events: none;
  display: flex;
  justify-content: center;
  padding: 0;
}

#tarot-card-info.hidden { display: none !important; }

#tarot-card-info-inner {
  width: 100%;
  max-width: 100%;
  background: rgba(8, 8, 16, 0.95);
  border-radius: 0;
  padding: 14px 20px;
  font-family: 'Cobblestone', serif;
  font-size: 1.5rem;
  color: #d4c08a;
  text-align: center;
  line-height: 1.6;
  box-shadow: 0 4px 24px rgba(0,0,0,0.7);
  pointer-events: auto;
}
#tarot-card-info-inner .restart-link {
  display: block;
  font-size: 1.1rem;
  margin-top: 8px;
  color: var(--accent2);
  cursor: pointer;
  text-decoration: underline;
}
/* ─── Tarot Hand ────────────────────────────────── */
#tarot-hand {
  position: fixed;
  top: 124px;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  z-index: 1000;
  pointer-events: none;
}

#tarot-hand::before {
  content: '';
  position: absolute;
  top: -32px;
  left: 0;
  right: 0;
  bottom: -32px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    #0f0f1a 20%,
    #0f0f1a 80%,
    transparent 100%
  );
  z-index: -1;
}

.tarot-card {
  /* golden ratio: 110 × 1.618 ≈ 178 */
  width: 110px;
  height: 178px;
  border-radius: 10px;
  overflow: hidden;
  background: #080812;
  pointer-events: all;
  cursor: pointer;
  border: 2px solid #c9a227;
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(201, 162, 39, 0.25),
    /* pixel glow layer 1 */
    3px 0 0 1px #7c3aed, -3px 0 0 1px #7c3aed,
    0 3px 0 1px #7c3aed, 0 -3px 0 1px #7c3aed,
    /* pixel glow layer 2 */
    6px 0 0 0 rgba(168,85,247,0.45), -6px 0 0 0 rgba(168,85,247,0.45),
    0 6px 0 0 rgba(168,85,247,0.45), 0 -6px 0 0 rgba(168,85,247,0.45),
    6px 6px 0 0 rgba(168,85,247,0.2), -6px 6px 0 0 rgba(168,85,247,0.2),
    6px -6px 0 0 rgba(168,85,247,0.2), -6px -6px 0 0 rgba(168,85,247,0.2),
    /* depth */
    0 14px 36px rgba(0, 0, 0, 0.85);
  transform-origin: center center;
  animation: tarot-pixel-glow 2.4s ease-in-out infinite;
}

.tarot-card img:not(.reliq-overlay) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Left card */
.tarot-card:nth-child(1) {
  animation: tarot-float-l 4s ease-in-out infinite, tarot-pixel-glow 2.4s ease-in-out infinite;
  animation-delay: -0.8s, -0.4s;
  z-index: 1;
}
/* Center card */
.tarot-card:nth-child(2) {
  animation: tarot-float-c 4s ease-in-out infinite, tarot-pixel-glow 2.4s ease-in-out infinite;
  animation-delay: 0s, -1.2s;
  z-index: 3;
}
/* Right card */
.tarot-card:nth-child(3) {
  animation: tarot-float-r 4s ease-in-out infinite, tarot-pixel-glow 2.4s ease-in-out infinite;
  animation-delay: -1.6s, -2s;
  z-index: 2;
}

@keyframes tarot-float-l {
  0%, 100% { transform: translateY(12px) rotate(-2.5deg); }
  50%       { transform: translateY(4px)  rotate(1deg); }
}
@keyframes tarot-float-c {
  0%, 100% { transform: translateY(0px)  rotate(1.5deg); }
  50%       { transform: translateY(-8px) rotate(-1deg); }
}
@keyframes tarot-float-r {
  0%, 100% { transform: translateY(12px) rotate(2.5deg); }
  50%       { transform: translateY(4px)  rotate(-1deg); }
}

.tarot-card--fade-out {
  animation: none !important;
  opacity: 0 !important;
  transition: opacity 0.5s !important;
  pointer-events: none !important;
}

#tarot-hand.fading-out {
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

/* ─── Pixel explosion fragments ─────────────────── */
@keyframes pixel-scatter {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  60%  { opacity: 0.8; }
  100% { transform: translate(var(--px-dx), var(--px-dy)) scale(0); opacity: 0; }
}

.die-item--exploding {
  animation: die-crumble 0.22s ease-in forwards !important;
  pointer-events: none;
}
@keyframes die-crumble {
  0%   { transform: scale(1);    opacity: 1; }
  60%  { transform: scale(1.15); opacity: 0.6; }
  100% { transform: scale(0);    opacity: 0; }
}

@keyframes tarot-pixel-glow {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px rgba(201,162,39,0.12),
      3px 0 0 1px rgba(124,58,237,0.25), -3px 0 0 1px rgba(124,58,237,0.25),
      0 3px 0 1px rgba(124,58,237,0.25), 0 -3px 0 1px rgba(124,58,237,0.25),
      6px 0 0 0 rgba(168,85,247,0.12), -6px 0 0 0 rgba(168,85,247,0.12),
      0 6px 0 0 rgba(168,85,247,0.12), 0 -6px 0 0 rgba(168,85,247,0.12),
      6px 6px 0 0 rgba(168,85,247,0.06), -6px 6px 0 0 rgba(168,85,247,0.06),
      6px -6px 0 0 rgba(168,85,247,0.06), -6px -6px 0 0 rgba(168,85,247,0.06),
      0 14px 36px rgba(0,0,0,0.85);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(201,162,39,0.18),
      3px 0 0 1px rgba(192,38,211,0.3), -3px 0 0 1px rgba(192,38,211,0.3),
      0 3px 0 1px rgba(192,38,211,0.3), 0 -3px 0 1px rgba(192,38,211,0.3),
      6px 0 0 0 rgba(192,38,211,0.15), -6px 0 0 0 rgba(192,38,211,0.15),
      0 6px 0 0 rgba(192,38,211,0.15), 0 -6px 0 0 rgba(192,38,211,0.15),
      6px 6px 0 0 rgba(192,38,211,0.08), -6px 6px 0 0 rgba(192,38,211,0.08),
      6px -6px 0 0 rgba(192,38,211,0.08), -6px -6px 0 0 rgba(192,38,211,0.08),
      9px 0 0 0 rgba(192,38,211,0.04), -9px 0 0 0 rgba(192,38,211,0.04),
      0 9px 0 0 rgba(192,38,211,0.04), 0 -9px 0 0 rgba(192,38,211,0.04),
      0 14px 36px rgba(0,0,0,0.85);
  }
}

.tarot-card:hover {
  z-index: 10 !important;
  box-shadow:
    inset 0 0 0 1px rgba(201,162,39,0.4),
    3px 0 0 1px rgba(232,121,249,0.4), -3px 0 0 1px rgba(232,121,249,0.4),
    0 3px 0 1px rgba(232,121,249,0.4), 0 -3px 0 1px rgba(232,121,249,0.4),
    6px 0 0 0 rgba(232,121,249,0.2), -6px 0 0 0 rgba(232,121,249,0.2),
    0 6px 0 0 rgba(232,121,249,0.2), 0 -6px 0 0 rgba(232,121,249,0.2),
    6px 6px 0 0 rgba(232,121,249,0.1), -6px 6px 0 0 rgba(232,121,249,0.1),
    6px -6px 0 0 rgba(232,121,249,0.1), -6px -6px 0 0 rgba(232,121,249,0.1),
    9px 0 0 0 rgba(232,121,249,0.06), -9px 0 0 0 rgba(232,121,249,0.06),
    0 9px 0 0 rgba(232,121,249,0.06), 0 -9px 0 0 rgba(232,121,249,0.06),
    0 20px 50px rgba(0,0,0,0.9);
}
