/* ============================================================
   MYTHLINGS – Main Stylesheet
   Mobile-first, portrait orientation
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --color-bg:           #1a0a2e;
  --color-bg-secondary: #2d1055;
  --color-bg-card:      #2a1a4a;
  --color-accent:       #9333ea;
  --color-accent-light: #c084fc;
  --color-gold:         #f59e0b;
  --color-gold-light:   #fde68a;
  --color-text:         #f3e8ff;
  --color-text-muted:   #a78bca;
  --color-danger:       #ef4444;
  --color-success:      #22c55e;

  --card-width:   90px;
  --card-height:  130px;
  --card-radius:  10px;

  --font-main:    'Segoe UI', system-ui, sans-serif;
  --font-title:   Georgia, serif;

  --anim-fast:    150ms;
  --anim-normal:  300ms;
  --anim-slow:    500ms;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.4;
  touch-action: manipulation;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ---------- Screen System ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--anim-normal);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ---------- Language Selection Screen ---------- */
#screen-lang {
  background: var(--color-bg);
  justify-content: center;
  align-items: center;
}

.lang-select {
  text-align: center;
  padding: 2rem;
}

.game-title {
  font-family: var(--font-title);
  font-size: 3rem;
  color: var(--color-gold);
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.lang-prompt {
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.lang-buttons {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.btn-lang {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.2rem 2rem;
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-accent);
  border-radius: 12px;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--anim-fast), transform var(--anim-fast);
  min-width: 120px;
}

.btn-lang:active {
  transform: scale(0.96);
  background: var(--color-accent);
}

.lang-flag {
  font-size: 2rem;
}

/* ---------- Main Menu Screen ---------- */
#screen-menu {
  background: var(--color-bg);
  justify-content: center;
  align-items: center;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #4a1080 0%, #1a0a2e 70%);
  pointer-events: none;
}

.menu-content {
  position: relative;
  text-align: center;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 400px;
}

.game-subtitle {
  color: var(--color-text-muted);
  margin-bottom: 2.5rem;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.main-menu {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.menu-footer {
  margin-top: 2rem;
}

/* ---------- Buttons ---------- */
.btn-menu {
  width: 100%;
  padding: 0.9rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--anim-fast), opacity var(--anim-fast);
  letter-spacing: 0.03em;
}

.btn-menu:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  color: #fff;
  box-shadow: 0 4px 15px rgba(147, 51, 234, 0.4);
}

.btn-secondary {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-accent);
}

.btn-tertiary {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.btn-wide {
  width: 100%;
}

.btn-back {
  background: none;
  border: none;
  color: var(--color-accent-light);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.5rem;
}

.btn-lang-toggle {
  background: none;
  border: 1px solid var(--color-text-muted);
  color: var(--color-text-muted);
  border-radius: 6px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  cursor: pointer;
  letter-spacing: 0.1em;
}

/* ---------- Solo Setup Screen ---------- */
#screen-solo-setup {
  background: var(--color-bg);
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-bg-secondary);
}

.screen-header h2 {
  font-size: 1.1rem;
  color: var(--color-gold);
}

.setup-content {
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

.setup-section label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}

.setup-section input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-accent);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 1rem;
  outline: none;
}

.setup-section input[type="text"]:focus {
  border-color: var(--color-accent-light);
}

.opponent-selector,
.difficulty-selector {
  display: flex;
  gap: 0.5rem;
}

.btn-count,
.btn-diff {
  flex: 1;
  padding: 0.65rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-accent);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--anim-fast);
}

.btn-count.active,
.btn-diff.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* ---------- Game Screen Layout ---------- */
#screen-game {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--color-bg);
  height: 100%;
  overflow: hidden;
}

/* Opponents Bar (top) */
.game-opponents {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-secondary);
  overflow-x: auto;
  border-bottom: 1px solid rgba(147, 51, 234, 0.3);
  min-height: 64px;
  align-items: center;
}

.opponent-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 0.3rem 0.5rem;
  background: var(--color-bg-card);
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.opponent-chip.active-turn {
  border-color: var(--color-gold);
}

.opponent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
}

.opponent-name {
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52px;
}

.opponent-level {
  color: var(--color-gold);
  font-weight: 700;
}

/* Game Table (middle) */
.game-table {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem;
  overflow: hidden;
}

.decks-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
}

.deck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.deck-card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  border: 2px solid var(--color-accent);
}

.door-back {
  background: linear-gradient(135deg, #4a1080, #2d1055);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.4);
}

.treasure-back {
  background: linear-gradient(135deg, #78350f, #451a03);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.deck-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.active-card-area {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  border: 2px dashed rgba(147, 51, 234, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Phase Indicator */
.phase-indicator {
  background: rgba(45, 16, 85, 0.8);
  border: 1px solid var(--color-accent);
  border-radius: 20px;
  padding: 0.3rem 1rem;
  font-size: 0.8rem;
  color: var(--color-accent-light);
  letter-spacing: 0.05em;
}

/* Combat Area */
.combat-area {
  width: 100%;
  background: rgba(45, 16, 85, 0.9);
  border: 1px solid var(--color-accent);
  border-radius: 12px;
  padding: 0.75rem;
}

.combat-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.combat-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.combat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.combat-strength {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-gold);
}

.combat-vs {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.combat-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Player Area (bottom) */
.game-player {
  background: var(--color-bg-secondary);
  border-top: 1px solid rgba(147, 51, 234, 0.3);
  display: flex;
  flex-direction: column;
  max-height: 45vh;
}

.player-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(147, 51, 234, 0.2);
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.player-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.player-stats {
  display: flex;
  gap: 1rem;
}

.stat-level,
.stat-strength {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-gold);
}

.player-equipment-mini {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 40%;
}

/* Hand Cards */
.hand-area {
  flex: 1;
  overflow: hidden;
  padding: 0.5rem 0.75rem;
}

.hand-cards {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  height: 100%;
  align-items: flex-start;
}

.hand-cards::-webkit-scrollbar {
  height: 3px;
}

.hand-cards::-webkit-scrollbar-thumb {
  background: var(--color-accent);
  border-radius: 2px;
}

/* Action Bar */
.action-bar {
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  border-top: 1px solid rgba(147, 51, 234, 0.2);
}

.btn-action {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  background: var(--color-accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--anim-fast);
  white-space: nowrap;
}

.btn-action:active {
  transform: scale(0.95);
}

.btn-action.btn-danger {
  background: var(--color-danger);
}

.btn-action.btn-success {
  background: var(--color-success);
}

.btn-action:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Cards ---------- */
.card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--anim-fast), border-color var(--anim-fast);
  scroll-snap-align: start;
  position: relative;
  user-select: none;
}

.card:active {
  transform: scale(0.97);
}

.card.selected {
  border-color: var(--color-gold);
  transform: translateY(-8px);
}

.card-type-monster  { background: linear-gradient(160deg, #7f1d1d, #1c0a0a); }
.card-type-treasure { background: linear-gradient(160deg, #78350f, #1c0a00); }
.card-type-curse    { background: linear-gradient(160deg, #1e1b4b, #0a0010); }
.card-type-race     { background: linear-gradient(160deg, #064e3b, #001a0f); }
.card-type-class    { background: linear-gradient(160deg, #1e3a5f, #000e1f); }
.card-type-help     { background: linear-gradient(160deg, #4a044e, #150016); }

.card-header {
  padding: 0.3rem 0.4rem;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  opacity: 0.75;
}

.card-image {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  background: rgba(0,0,0,0.2);
}

.card-body {
  padding: 0.3rem 0.4rem;
}

.card-name {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.15rem;
}

.card-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-gold);
}

.card-badge {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--color-gold-light);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-accent);
  border-radius: 20px;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  color: var(--color-text);
  z-index: 1000;
  max-width: 90vw;
  text-align: center;
  transition: opacity var(--anim-normal), transform var(--anim-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 500;
  transition: opacity var(--anim-normal);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-accent);
  border-radius: 20px 20px 0 0;
  padding: 1.5rem 1rem;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  padding-bottom: calc(var(--safe-bottom) + 1.5rem);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

/* ---------- Animations ---------- */
@keyframes levelUp {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: var(--color-gold); }
  100% { transform: scale(1); }
}

.animate-level-up {
  animation: levelUp 0.5s ease-in-out;
}

@keyframes cardFlip {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

.animate-flip {
  animation: cardFlip var(--anim-slow) ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

.animate-shake {
  animation: shake 0.4s ease-in-out;
}

/* ---------- Scrollbar (Desktop) ---------- */
@media (min-width: 480px) {
  :root {
    --card-width:  100px;
    --card-height: 145px;
  }
}

/* ---------- Safe Area for Notched Phones ---------- */
@supports (padding-top: env(safe-area-inset-top)) {
  .screen {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- Card Badges Row ---------- */
.card-badges-row {
  position: absolute;
  bottom: 0.25rem;
  left: 0.25rem;
  right: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.cbadge {
  font-size: 0.42rem;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.cbadge-warn    { background: #b45309; color: #fef3c7; }
.cbadge-class   { background: #1e3a5f; color: #bfdbfe; }
.cbadge-race    { background: #064e3b; color: #a7f3d0; }
.cbadge-instant { background: #065f46; color: #6ee7b7; }
.cbadge-react   { background: #3730a3; color: #c7d2fe; }
.cbadge-danger  { background: #991b1b; color: #fecaca; }
.cbadge-boss    { background: #7f1d1d; color: #fca5a5; border: 1px solid #ef4444; }

/* ---------- Action Bar Waiting Label ---------- */
.action-waiting {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 0.6rem 0;
  font-style: italic;
}

.btn-primary-action {
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  color: #fff;
  box-shadow: 0 3px 10px rgba(147,51,234,0.4);
}

/* ---------- Combat Outcome Hint ---------- */
.combat-outcome-hint {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  margin-top: 0.25rem;
}

.outcome-win  { background: rgba(34,197,94,0.2);  color: var(--color-success); }
.outcome-lose { background: rgba(239,68,68,0.2);   color: var(--color-danger); }

/* ---------- Equipment Mini Badges ---------- */
.equip-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 0.9rem;
  background: var(--color-bg-card);
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(147,51,234,0.3);
  transition: border-color var(--anim-fast);
}

.equip-mini-badge:hover { border-color: var(--color-accent); }
.equip-mini-race  { border-color: rgba(6,78,59,0.5); }
.equip-mini-class { border-color: rgba(30,58,95,0.5); }

/* ---------- Card Detail Modal ---------- */
.card-detail {}

.card-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.card-detail-emoji {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.card-detail-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

.card-detail-type {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.15rem;
}

.card-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(147,51,234,0.1);
}

.detail-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex-shrink: 0;
}

.detail-value {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
}

.detail-level  { color: var(--color-danger); font-size: 1.1rem; }
.detail-bonus  { color: var(--color-gold);   font-size: 1.1rem; }

.detail-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: 0.25rem;
}

.detail-bad-things {
  background: rgba(127,29,29,0.25);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: #fca5a5;
  margin-top: 0.25rem;
}

.detail-effect {
  background: rgba(45,16,85,0.5);
  border: 1px solid rgba(147,51,234,0.3);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--color-accent-light);
  margin-top: 0.25rem;
}

.detail-effect-curse {
  background: rgba(30,27,75,0.5);
  border-color: rgba(99,102,241,0.4);
  color: #a5b4fc;
}

.detail-special-badge {
  display: inline-block;
  background: rgba(127,29,29,0.4);
  color: #fca5a5;
  border: 1px solid #ef4444;
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.25rem;
}

.detail-ability {
  background: rgba(6,78,59,0.2);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.25rem;
}

.detail-ability-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #6ee7b7;
  margin-bottom: 0.2rem;
}

.detail-ability-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.detail-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.detail-flag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-flag-warn    { background: rgba(180,83,9,0.3);   color: #fde68a; }
.detail-flag-class   { background: rgba(30,58,95,0.4);   color: #bfdbfe; }
.detail-flag-race    { background: rgba(6,78,59,0.4);    color: #a7f3d0; }
.detail-flag-instant { background: rgba(6,95,70,0.4);   color: #6ee7b7; }
.detail-flag-special { background: rgba(109,40,217,0.3); color: #c4b5fd; }

.detail-section-title {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(147,51,234,0.2);
}

.tag-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: flex-end; }

.tag-chip {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  background: rgba(147,51,234,0.2);
  border: 1px solid rgba(147,51,234,0.4);
  border-radius: 4px;
  color: var(--color-accent-light);
}

/* ---------- Player Info Modal ---------- */
.player-info-modal h3 {
  color: var(--color-gold);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

/* ---------- Rules Modal ---------- */
.rules-modal {}
.rules-title   { color: var(--color-gold); margin-bottom: 1rem; }
.rules-section { color: var(--color-accent-light); margin-top: 1rem; margin-bottom: 0.3rem; font-size: 0.95rem; }

/* ---------- Settings Modal ---------- */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(147,51,234,0.15);
  gap: 0.5rem;
}

.settings-lang-btns,
.settings-toggle {
  display: flex;
  gap: 0.35rem;
}

.btn-setting {
  padding: 0.35rem 0.75rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-accent);
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--anim-fast);
}

.btn-setting.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* ---------- Combat Log ---------- */
#combat-log {
  max-height: 80px;
  overflow-y: auto;
  padding: 0.25rem 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.log-entry {
  padding: 0.1rem 0;
  border-bottom: 1px solid rgba(147,51,234,0.08);
  line-height: 1.3;
}

/* ---------- Action Sheet (Phase 4) ---------- */
.action-sheet {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-sheet-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: rgba(45,16,85,0.5);
  border: 1px solid rgba(147,51,234,0.3);
  border-radius: 10px;
  margin-bottom: 0.25rem;
}

.action-sheet-emoji {
  font-size: 2rem;
  flex-shrink: 0;
}

.action-sheet-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.action-sheet-type {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.action-sheet-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-action-sheet {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid rgba(147,51,234,0.35);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background var(--anim-fast), transform var(--anim-fast);
}

.btn-action-sheet:active {
  transform: scale(0.98);
}

.btn-as-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.btn-as-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

.btn-as-warning {
  background: #b45309;
  border-color: #d97706;
  color: #fde68a;
}

/* ---------- Action Bar – new styles ---------- */
.btn-action.btn-primary-action {
  background: var(--color-accent);
  font-size: 0.95rem;
  padding: 0.6rem 1.25rem;
}

.btn-action.btn-warning {
  background: #b45309;
  color: #fde68a;
}

.charity-info {
  flex: 1 1 100%;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-danger);
  padding: 0.25rem 0;
  animation: pulse-warn 1.2s ease-in-out infinite;
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ---------- Combat log in game-table ---------- */
.game-table #combat-log {
  margin-top: 0.25rem;
}

/* ============================================================
   PHASE 5: UI POLISH
   ============================================================ */

/* ---------- Hand Cards: Mobile-first scrollable strip ---------- */
/* Default (mobile): horizontal scroll, no rotation, every card fully visible */
.hand-cards {
  padding: 0.5rem 0.75rem;
  align-items: center;
  scrollbar-width: none;
}
.hand-cards::-webkit-scrollbar { display: none; }

.hand-cards .card {
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

/* Gentle lift on tap (mobile) */
.hand-cards .card:active {
  transform: translateY(-10px) scale(1.04);
  z-index: 20;
  box-shadow: 0 10px 24px rgba(0,0,0,0.6);
}

/* ---------- Fan Layout: desktop / tablet only (≥ 600 px) ---------- */
@media (min-width: 600px) {
  .hand-area {
    overflow-x: hidden;
    overflow-y: visible;
  }

  .hand-cards {
    gap: 0;
    padding: 0.75rem 1.25rem 0.35rem;
    align-items: flex-end;
    scroll-snap-type: none;
    overflow-x: visible;
  }

  .hand-cards .card {
    margin-left: -22px;
    transform-origin: bottom center;
    transition: transform 200ms ease, box-shadow 200ms ease;
    box-shadow: -2px 4px 10px rgba(0,0,0,0.5);
    scroll-snap-align: none;
  }

  .hand-cards .card:first-child { margin-left: 0; }

  .hand-cards .card:nth-child(1)  { transform: rotate(-7deg) translateY(3px); }
  .hand-cards .card:nth-child(2)  { transform: rotate(-4deg) translateY(1px); }
  .hand-cards .card:nth-child(3)  { transform: rotate(-1deg); }
  .hand-cards .card:nth-child(4)  { transform: rotate(2deg) translateY(1px); }
  .hand-cards .card:nth-child(5)  { transform: rotate(4deg) translateY(2px); }
  .hand-cards .card:nth-child(6)  { transform: rotate(6deg) translateY(3px); }
  .hand-cards .card:nth-child(7)  { transform: rotate(7deg) translateY(4px); }
  .hand-cards .card:nth-child(8)  { transform: rotate(8deg) translateY(5px); }
  .hand-cards .card:nth-child(n+9) { transform: rotate(8deg) translateY(5px); }

  .hand-cards .card:active {
    transform: translateY(-22px) rotate(0deg) scale(1.06) !important;
    z-index: 20;
    box-shadow: 0 16px 36px rgba(0,0,0,0.7);
  }

  .hand-cards .card-type-monster:hover  { box-shadow: 0 0 0 2px #ef4444, -2px 4px 10px rgba(0,0,0,0.5); }
  .hand-cards .card-type-treasure:hover { box-shadow: 0 0 0 2px #f59e0b, -2px 4px 10px rgba(0,0,0,0.5); }
  .hand-cards .card-type-curse:hover    { box-shadow: 0 0 0 2px #6366f1, -2px 4px 10px rgba(0,0,0,0.5); }
  .hand-cards .card-type-race:hover     { box-shadow: 0 0 0 2px #10b981, -2px 4px 10px rgba(0,0,0,0.5); }
  .hand-cards .card-type-class:hover    { box-shadow: 0 0 0 2px #3b82f6, -2px 4px 10px rgba(0,0,0,0.5); }
  .hand-cards .card-type-help:hover     { box-shadow: 0 0 0 2px #a855f7, -2px 4px 10px rgba(0,0,0,0.5); }
}

/* ---------- Deck 3D Stack Effect ---------- */
.deck-card {
  position: relative;
  box-shadow:
    3px 3px 0 rgba(0,0,0,0.4),
    6px 6px 0 rgba(0,0,0,0.25);
}

.door-back {
  box-shadow:
    0 4px 12px rgba(147,51,234,0.4),
    3px 3px 0 rgba(50,10,100,0.7),
    6px 6px 0 rgba(50,10,100,0.4);
}

.treasure-back {
  box-shadow:
    0 4px 12px rgba(245,158,11,0.3),
    3px 3px 0 rgba(100,40,5,0.7),
    6px 6px 0 rgba(100,40,5,0.4);
}

/* ---------- Deck Count Badge ---------- */
.deck-count {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0,0,0,0.75);
  color: var(--color-gold);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}

/* ---------- Phase Indicator ---------- */
.phase-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 300ms;
}

.phase-icon {
  font-size: 0.95rem;
}

@keyframes phaseFlash {
  0%   { opacity: 1;   transform: scale(1); }
  40%  { opacity: 0.6; transform: scale(1.08); }
  100% { opacity: 1;   transform: scale(1); }
}

.phase-changed {
  animation: phaseFlash 400ms ease-out;
}

/* ---------- Combat Area Win/Lose Glow ---------- */
.combat-area {
  transition: border-color 400ms, box-shadow 400ms;
}

.combat-area.combat-winning {
  border-color: var(--color-success);
  box-shadow: 0 0 16px rgba(34,197,94,0.25);
}

.combat-area.combat-losing {
  border-color: var(--color-danger);
  box-shadow: 0 0 16px rgba(239,68,68,0.25);
}

.combat-area.combat-winning .combat-strength:first-of-type,
.player-side .combat-strength {
  transition: color 400ms;
}
.combat-area.combat-winning .player-side .combat-strength {
  color: var(--color-success);
}
.combat-area.combat-losing .player-side .combat-strength {
  color: var(--color-danger);
}

/* ---------- Toast Slide-In Animation ---------- */
.toast {
  animation: toastSlide 0.3s ease-out;
}

@keyframes toastSlide {
  from { transform: translateX(-50%) translateY(-12px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);     opacity: 1; }
}

/* ---------- Active Card Reveal Pulse ---------- */
.active-card-area .card {
  box-shadow: 0 0 0 0 rgba(147,51,234,0);
  animation: cardReveal 0.5s ease-out;
}

@keyframes cardReveal {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

/* ---------- Bigger Level / Strength Display ---------- */
.stat-value {
  font-size: 1.5rem;
}

.stat-level .stat-value {
  font-size: 1.8rem;
  text-shadow: 0 0 10px rgba(245,158,11,0.4);
}

/* ---------- Opponent Chip Active Pulse ---------- */
@keyframes chipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(147,51,234,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(147,51,234,0); }
}

.opponent-chip.active-turn {
  animation: chipPulse 1.8s ease-in-out infinite;
}

/* ---------- Action Sheet Slide-Up ---------- */
#modal-overlay:not(.hidden) .action-sheet {
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Hand area needs position:relative for the card-count ::before indicator */
.hand-area {
  position: relative;
}

/* Hand Card Count Indicator */
.hand-area::before {
  content: attr(data-count);
  position: absolute;
  top: 0.15rem;
  right: 0.5rem;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-weight: 600;
  pointer-events: none;
}

/* ---------- Equipment Mini Badge Active Style ---------- */
.equip-mini-badge {
  cursor: pointer;
  transition: transform 150ms, filter 150ms;
}

.equip-mini-badge:active {
  transform: scale(1.25);
  filter: brightness(1.3);
}

/* ---------- Combat Strength Animated Counter ---------- */
.combat-strength {
  transition: color 300ms, transform 300ms;
}

.combat-strength.changed {
  animation: strengthBump 0.3s ease-out;
}

@keyframes strengthBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: var(--color-gold); }
  100% { transform: scale(1); }
}

/* ---------- Deck Hover Feedback ---------- */
.deck:hover .deck-card {
  transform: translateY(-2px);
  transition: transform 150ms;
}

/* ============================================================
   PHASE 7 – MULTIPLAYER LOBBY
   ============================================================ */

/* ── Lobby Screen Layout ─────────────────────────────────── */

#screen-lobby {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0;
}

#screen-lobby .screen-header {
  flex-shrink: 0;
}

.lobby-section {
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lobby-section.hidden { display: none; }

/* ── Server Connect Panel ────────────────────────────────── */

.lobby-server-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lobby-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lobby-input {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.95rem;
  padding: 0.6rem 0.8rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 150ms;
}

.lobby-input:focus {
  outline: none;
  border-color: var(--color-gold);
}

.code-input {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-align: center;
  text-transform: uppercase;
}

.lobby-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-align: center;
  margin: 0;
  font-family: monospace;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}

.lobby-status {
  min-height: 1.4rem;
  font-size: 0.85rem;
  text-align: center;
  color: var(--color-text-muted);
  transition: color 200ms;
}

.lobby-status.ok    { color: #4ade80; }
.lobby-status.error { color: #f87171; }

/* ── Tabs ────────────────────────────────────────────────── */

.lobby-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

.lobby-tab {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 0.6rem 0;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.lobby-tab.active {
  background: var(--color-surface);
  color: var(--color-gold);
  font-weight: 600;
}

.lobby-panel        { display: flex; flex-direction: column; gap: 0.75rem; }
.lobby-panel.hidden { display: none; }

/* ── Room Code Display ───────────────────────────────────── */

.lobby-code-display {
  background: var(--color-surface);
  border: 1px solid var(--color-gold);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.lobby-code-display.hidden { display: none; }

.lobby-share-label {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.lobby-room-code {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--color-gold);
  text-shadow: 0 0 12px rgba(212,175,55,0.5);
  font-family: monospace;
}

/* ── Player List ─────────────────────────────────────────── */

.lobby-player-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lobby-player-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.25s ease-out;
}

.lobby-player-card.ready {
  border-color: #4ade80;
  background: rgba(74,222,128,0.07);
}

.lobby-player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-purple), var(--color-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.lobby-player-info {
  flex: 1;
  min-width: 0;
}

.lobby-player-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-player-tags {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.lobby-player-tag {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: var(--color-text-muted);
}

.lobby-player-tag.host  { background: rgba(212,175,55,0.2); color: var(--color-gold); }
.lobby-player-tag.ready { background: rgba(74,222,128,0.2); color: #4ade80; }

.lobby-ready-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ── Room Actions ────────────────────────────────────────── */

.lobby-room-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ── Fade / Slide animations ─────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PHASE 8 – AUDIO & VISUAL POLISH
   ============================================================ */

/* ── Card Quality Tiers ──────────────────────────────────── */

/* Uncommon – subtle blue-green shimmer */
.card.card-quality-uncommon {
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.2);
}

/* Rare – purple glow + shimmer sweep */
.card.card-quality-rare {
  border-color: rgba(167, 139, 250, 0.65);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.35), inset 0 0 8px rgba(139, 92, 246, 0.1);
  position: relative;
  overflow: hidden;
}
.card.card-quality-rare::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 30%,
    rgba(167,139,250,0.2) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
  pointer-events: none;
  border-radius: inherit;
}

/* Epic – gold glow + faster shimmer */
.card.card-quality-epic {
  border-color: rgba(212, 175, 55, 0.8);
  box-shadow: 0 0 18px rgba(212, 175, 55, 0.5), inset 0 0 10px rgba(212, 175, 55, 0.1);
  position: relative;
  overflow: hidden;
}
.card.card-quality-epic::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 25%,
    rgba(255, 215, 0, 0.25) 50%,
    transparent 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  pointer-events: none;
  border-radius: inherit;
}

@keyframes shimmer {
  0%   { background-position: 150% center; }
  100% { background-position: -50% center; }
}

/* ── Combat Flash ────────────────────────────────────────── */

.combat-area.combat-flash {
  animation: combatBolt 0.35s ease-out;
}

@keyframes combatBolt {
  0%   { box-shadow: 0 0 0 rgba(250,204,21,0); }
  30%  { box-shadow: 0 0 30px rgba(250,204,21,0.9), inset 0 0 20px rgba(250,204,21,0.4); }
  100% { box-shadow: 0 0 0 rgba(250,204,21,0); }
}

/* Lightning bolt overlay during combat flash */
.combat-area.combat-flash::before {
  content: '⚡';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  animation: boltFade 0.35s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

@keyframes boltFade {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
  50%  { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
}

/* ── Screen Flash (victory / defeat) ────────────────────── */

.screen-flash {
  position: fixed;
  inset: 0;
  background: var(--flash-color, rgba(212,175,55,0.25));
  pointer-events: none;
  z-index: 9998;
  animation: screenFlash 0.5s ease-out forwards;
}

@keyframes screenFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Improved Game-Over particles ───────────────────────── */

/* Game-over modal glow when winning */
.modal .game-over-win {
  text-shadow: 0 0 20px rgba(212,175,55,0.8);
}

/* ── Settings – Music toggle ─────────────────────────────── */

/* (settings rows already styled; music uses same classes) */

/* ── Tutorial Overlay (Phase 9) ─────────────────────────── */

/* Spotlight: positioned over the target element.
   The massive box-shadow creates the dark backdrop around it. */
.tutorial-spotlight {
  position: fixed;
  z-index: 9999;
  border-radius: 10px;
  outline: 3px solid rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78);
  pointer-events: none;
  transition: top 0.28s ease, left 0.28s ease,
              width 0.28s ease, height 0.28s ease;
}

/* Speech-bubble card shown next to the spotlight */
.tutorial-bubble {
  position: fixed;
  z-index: 10000;
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-gold);
  border-radius: 16px;
  padding: 1.1rem 1.25rem 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(212, 175, 55, 0.15);
  pointer-events: all;
  transition: top 0.28s ease, bottom 0.28s ease, left 0.28s ease;
  animation: tutBubbleIn 0.22s ease-out both;
}

@keyframes tutBubbleIn {
  from { opacity: 0; transform: scale(0.93); }
  to   { opacity: 1; transform: scale(1);    }
}

.tut-step-num {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.tut-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-gold);
  margin: 0 0 0.5rem;
}

.tut-body {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.55;
  margin: 0 0 0.9rem;
}

.tut-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-tut-skip {
  background: transparent;
  border: 1px solid var(--color-text-muted);
  color: var(--color-text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.btn-tut-skip:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

.btn-tut-next {
  background: var(--color-gold);
  border: none;
  color: #1a0a2e;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.15s;
}

.btn-tut-next:active {
  filter: brightness(0.9);
}

.tut-waiting {
  font-size: 0.8rem;
  color: var(--color-gold);
  font-style: italic;
  animation: pulse 1.4s ease-in-out infinite;
}

/* ============================================================
   MOBILE FIX – Portrait / iPhone (Comprehensive)
   ============================================================ */

/*
 * iOS Safari problem: `overflow: hidden` on body does NOT prevent the
 * rubber-band elastic scroll from revealing content outside the viewport.
 * Solution: use `position: fixed` on body AND #app so the browser treats
 * the entire page as a fixed viewport – no scrolling possible at all.
 */
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  /* height set via JS --vh variable for true iOS visual-viewport height */
  height: calc(var(--vh, 1vh) * 100);
}

/* Screens fill #app exactly */
.screen {
  height: 100%;
  width: 100%;
}

/* Game screen grid fills available height without overflow */
#screen-game {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

/* Middle section must shrink when space is tight – critical for grid 1fr */
.game-table {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Player area: contain all children, no overflow */
.game-player {
  overflow: hidden;
}

/* Action bar: wrap buttons rather than overflow horizontally */
.action-bar {
  flex-wrap: wrap;
  overflow: hidden;
}

/* Decks row: always fits within screen width */
.decks-area {
  max-width: 100%;
  overflow: hidden;
}

/* ── Mobile layout compaction (< 600px) ─────────────────── */
@media (max-width: 599px) {

  /* 1. Opponents bar: avatar LEFT, name+level stacked RIGHT */
  .game-opponents {
    min-height: unset;
    padding: 0.3rem 0.75rem;
    gap: 0.4rem;
  }

  .opponent-chip {
    display: grid;
    grid-template-columns: 32px 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.4rem;
    row-gap: 0;
    align-items: center;
    min-width: unset;
    padding: 0.25rem 0.5rem;
  }

  .opponent-avatar {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .opponent-name {
    grid-column: 2;
    grid-row: 1;
    max-width: unset;
    font-size: 0.7rem;
    align-self: end;
  }

  .opponent-level {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.7rem;
    align-self: start;
  }

  /* 2. Player status: stats INLINE next to name, smaller numbers */
  .player-info {
    flex-direction: row;
    align-items: baseline;
    gap: 0.6rem;
    flex-wrap: wrap;
  }

  .player-stats {
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  .stat-level .stat-value {
    font-size: 1rem;
    text-shadow: none;
  }

  .player-status {
    padding: 0.3rem 0.75rem;
  }

  /* 3. Action buttons: smaller so 3 fit in one row */
  .action-bar {
    padding: 0.3rem 0.5rem;
    gap: 0.35rem;
    flex-wrap: nowrap;
  }

  .btn-action {
    padding: 0.45rem 0.6rem;
    font-size: 0.78rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
  }

  /* 4. Hide combat-log and phase-indicator – saves space in game-table */
  #combat-log    { display: none; }
  #phase-indicator { display: none; }
}

/* ── Landscape orientation warning ──────────────────────── */
@media screen and (orientation: landscape) and (max-height: 600px) {
  #app > .screen {
    display: none !important;
    pointer-events: none;
  }
  #app::after {
    content: '↩  Bitte drehe dein Gerät ins Hochformat  ·  Please rotate to portrait mode';
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    background: #1a0a2e;
    color: #f3e8ff;
    font-size: 1rem;
    text-align: center;
    padding: 2rem;
    z-index: 9999;
    white-space: pre-line;
  }
}
