/* ═══════════════════════════════════════════════
   CO-CREATION — Master Stylesheet
   ═══════════════════════════════════════════════ */

/* ─── RESET & VARIABLES ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a12;
  --bg-card: #151525;
  --bg-panel: #111120;
  --gold: #d4a843;
  --gold-dim: #8a6f2e;
  --seraphim: #e84030;
  --seraphim-bg: rgba(232, 64, 48, 0.08);
  --ophanim: #3db8c4;
  --ophanim-bg: rgba(61, 184, 196, 0.08);
  --cherubim: #d4a843;
  --cherubim-bg: rgba(212, 168, 67, 0.08);
  --malakim: #c8b0ff;
  --malakim-bg: rgba(200, 176, 255, 0.08);
  --starter: #666680;
  --neutral: #a0a0b0;
  --text: #e0dfe8;
  --text-dim: #888899;
  --text-bright: #ffffff;
  --danger: #ff4444;
  --success: #44cc66;
  --glory-bar: #d4a843;
  --faith-color: #d4a843;
  --authority-color: #e84030;
  --grace-color: #c8b0ff;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ─── LAYOUT ─── */
#game-container {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px;
  padding-bottom: 80px;
}

/* ─── TITLE SCREEN ─── */
#title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 20px;
  animation: fadeIn 1.5s ease;
}

#title-screen h1 {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--gold);
  margin-bottom: 8px;
  text-transform: uppercase;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

#title-screen .subtitle {
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  color: var(--text-dim);
  letter-spacing: 0.2em;
  margin-bottom: 40px;
}

#title-screen .verse {
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 500px;
  line-height: 1.6;
  margin-bottom: 40px;
}

.difficulty-select {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.difficulty-btn {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  padding: 10px 24px;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  font-family: inherit;
  border-radius: 4px;
}

.difficulty-btn:hover,
.difficulty-btn.selected {
  border-color: var(--gold);
  color: var(--gold);
}

.difficulty-btn.selected {
  background: rgba(212, 168, 67, 0.1);
}

.title-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.mute-btn {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mute-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ─── BUTTONS ─── */
.btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 14px 40px;
  font-size: 1rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  font-family: inherit;
  border-radius: 4px;
}

.btn:hover { background: var(--gold); color: var(--bg); }
.btn:active { transform: scale(0.97); }

.btn-small {
  padding: 6px 14px;
  font-size: 0.75rem;
}

.btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* ─── OPPONENT AREA ─── */
.opponent-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-radius: 8px;
  margin-bottom: 8px;
}

.opponent-area .player-name {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.glory-display {
  display: flex;
  align-items: center;
  gap: 6px;
}

.glory-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  transition: all 0.3s;
}

.glory-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.glory-bar-container {
  flex: 1;
  height: 8px;
  background: #222233;
  border-radius: 4px;
  overflow: hidden;
}

.glory-bar {
  height: 100%;
  background: var(--glory-bar);
  transition: width 0.5s ease;
  border-radius: 4px;
}

.opponent-info {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ─── STRONGHOLDS ─── */
.strongholds-row {
  display: flex;
  gap: 6px;
  min-height: 40px;
  padding: 4px 0;
  flex-wrap: wrap;
}

.stronghold-mini {
  font-size: 0.7rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s;
  max-width: 160px;
}

.stronghold-mini:hover { transform: scale(1.05); }
.stronghold-mini:active { transform: scale(0.98); }

.stronghold-mini .sh-name { font-weight: 600; font-size: 0.75rem; }
.stronghold-mini .sh-defense { font-size: 0.65rem; opacity: 0.7; }
.stronghold-mini.bastion { border-width: 2px; }

/* ─── MARKET ─── */
.market-area {
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 8px;
  margin: 6px 0;
}

.market-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.market-label .the-word-btn {
  cursor: pointer;
  transition: color 0.2s;
}

.market-label .the-word-btn:hover { color: var(--gold); }

.market-cards {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.market-cards > * { scroll-snap-align: start; }

/* ─── CARDS ─── */
.card {
  min-width: 155px;
  max-width: 155px;
  background: var(--bg-card);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 10;
}

.card:active { transform: translateY(-2px) scale(0.98); }

.card.seraphim { border-color: var(--seraphim); background: var(--seraphim-bg); }
.card.ophanim { border-color: var(--ophanim); background: var(--ophanim-bg); }
.card.cherubim { border-color: var(--cherubim); background: var(--cherubim-bg); }
.card.malakim { border-color: var(--malakim); background: var(--malakim-bg); }
.card.starter { border-color: var(--starter); }
.card.neutral { border-color: var(--neutral); }

.card-art {
  width: 100%;
  height: 70px;
  margin: 4px 0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2);
}

.card-art svg { width: 100%; height: 100%; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2px;
}

.card-name {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  flex: 1;
}

.card-cost {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--faith-color);
  background: rgba(212, 168, 67, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  white-space: nowrap;
}

.card-order {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.card.seraphim .card-order { color: var(--seraphim); }
.card.ophanim .card-order { color: var(--ophanim); }
.card.cherubim .card-order { color: var(--cherubim); }
.card.malakim .card-order { color: var(--malakim); }
.card.starter .card-order { color: var(--starter); }
.card.neutral .card-order { color: var(--neutral); }

.card-type { font-size: 0.58rem; color: var(--text-dim); margin-bottom: 3px; }

.card-text {
  font-size: 0.63rem;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}

.card-flavor {
  font-size: 0.58rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.3;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 4px;
}

.card-verse {
  font-size: 0.52rem;
  color: var(--gold-dim);
  text-align: right;
  margin-top: 2px;
}

.card-defense {
  font-size: 0.63rem;
  color: var(--authority-color);
  font-weight: 600;
}

/* ─── RESOURCES BAR ─── */
.resources-bar {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-radius: 8px;
  margin: 6px 0;
  align-items: center;
  flex-wrap: wrap;
}

.resource { display: flex; align-items: center; gap: 4px; }

.resource-value {
  font-size: 1.3rem;
  font-weight: 700;
  transition: all 0.3s;
}

.resource-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.resource.faith .resource-value { color: var(--faith-color); }
.resource.authority .resource-value { color: var(--authority-color); }
.resource.grace .resource-value { color: var(--grace-color); }

/* ─── HAND ─── */
.hand-area { padding: 4px 0; }

.hand-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 4px;
}

.hand-cards {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.hand-cards > * { scroll-snap-align: start; }

/* ─── PLAYED CARDS ─── */
.played-area { padding: 4px 0; }

.played-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 4px;
}

.played-cards { display: flex; gap: 4px; flex-wrap: wrap; }

.played-mini {
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid;
  background: var(--bg-card);
  opacity: 0.8;
}

.played-mini.seraphim { border-color: var(--seraphim); color: var(--seraphim); }
.played-mini.ophanim { border-color: var(--ophanim); color: var(--ophanim); }
.played-mini.cherubim { border-color: var(--cherubim); color: var(--cherubim); }
.played-mini.malakim { border-color: var(--malakim); color: var(--malakim); }
.played-mini.starter { border-color: var(--starter); color: var(--starter); }
.played-mini.neutral { border-color: var(--neutral); color: var(--neutral); }

/* ─── ACTIONS BAR ─── */
.actions-bar {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
  align-items: center;
}

.actions-bar .btn { padding: 8px 16px; font-size: 0.75rem; }

/* ─── LOG ─── */
.log-area {
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.log-entry { font-size: 0.7rem; color: var(--text-dim); line-height: 1.4; }
.log-entry .log-player { color: var(--gold-dim); font-weight: 600; }

/* ─── TURN INDICATOR ─── */
.turn-indicator {
  text-align: center;
  padding: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.turn-indicator.my-turn { color: var(--success); }
.turn-indicator.not-my-turn { color: var(--text-dim); }

/* ─── MODALS ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

.card-detail {
  background: var(--bg-card);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 24px;
  max-width: 380px;
  width: 90%;
  animation: modalSlideIn 0.3s ease;
}

.card-detail .detail-art {
  width: 100%;
  height: 120px;
  margin: 8px 0;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
}

.card-detail .detail-art svg { width: 100%; height: 100%; }

.card-detail .card-name { font-size: 1.2rem; margin-bottom: 4px; }
.card-detail .card-order { font-size: 0.8rem; margin-bottom: 8px; }
.card-detail .card-text { font-size: 0.9rem; margin-bottom: 12px; min-height: auto; }
.card-detail .card-flavor { font-size: 0.8rem; }
.card-detail .card-verse { font-size: 0.75rem; }
.card-detail .modal-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── CHOICE MODAL ─── */
.choice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 150;
  justify-content: center;
  align-items: center;
}

.choice-overlay.active { display: flex; }

.choice-panel {
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  animation: modalSlideIn 0.3s ease;
}

.choice-panel h3 {
  color: var(--gold);
  margin-bottom: 16px;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.choice-options { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.choice-options .btn { padding: 10px 20px; }

/* ─── WIN/STATS OVERLAY ─── */
.win-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.win-overlay.active { display: flex; }

.win-overlay h2 {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  color: var(--gold);
  letter-spacing: 0.2em;
  margin-bottom: 12px;
  animation: titleGlow 2s ease-in-out infinite alternate;
}

.win-overlay .win-verse {
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 24px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  margin-bottom: 24px;
  max-width: 400px;
  width: 100%;
}

.stat-item { display: flex; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 0.8rem; color: var(--text-dim); }
.stat-value { font-size: 0.8rem; color: var(--gold); font-weight: 600; }

/* ─── TUTORIAL ─── */
.tutorial-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

.tutorial-overlay.active { display: block; pointer-events: auto; }

.tutorial-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 301;
}

.tutorial-spotlight {
  position: absolute;
  z-index: 302;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.75);
  transition: all 0.4s ease;
  pointer-events: none;
}

.tutorial-tooltip {
  position: absolute;
  z-index: 303;
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 16px;
  max-width: 320px;
  width: 90vw;
  pointer-events: auto;
  animation: modalSlideIn 0.3s ease;
}

.tutorial-tooltip h4 {
  color: var(--gold);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.tutorial-tooltip p {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
}

.tutorial-tooltip .tutorial-btns { display: flex; gap: 8px; justify-content: flex-end; }

.tutorial-step-indicator {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes titleGlow {
  from { text-shadow: 0 0 20px rgba(212, 168, 67, 0.2); }
  to { text-shadow: 0 0 40px rgba(212, 168, 67, 0.5), 0 0 80px rgba(212, 168, 67, 0.2); }
}

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

@keyframes cardDraw {
  from { transform: translateY(40px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes cardPlay {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); opacity: 0.7; }
  100% { transform: translateY(-40px) scale(0.8); opacity: 0; }
}

@keyframes cardBuy {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes marketSlideIn {
  from { transform: translateX(60px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes damageShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(1px); }
}

@keyframes gloryPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); text-shadow: 0 0 20px currentColor; }
  100% { transform: scale(1); }
}

@keyframes gloryDamage {
  0% { transform: scale(1); color: var(--gold); }
  30% { transform: scale(1.2); color: var(--danger); }
  100% { transform: scale(1); color: var(--gold); }
}

@keyframes strongholdDestroy {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.5; }
  100% { transform: scale(0.5); opacity: 0; }
}

@keyframes offerGlow {
  0% { box-shadow: 0 0 0 rgba(212, 168, 67, 0); }
  50% { box-shadow: 0 0 30px rgba(212, 168, 67, 0.6); }
  100% { box-shadow: 0 0 0 rgba(212, 168, 67, 0); transform: scale(0.5); opacity: 0; }
}

@keyframes harmonyPulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(255,255,255,0); }
  50% { box-shadow: inset 0 0 20px rgba(255,255,255,0.1); }
}

/* Animation classes applied by JS */
.anim-draw { animation: cardDraw 0.35s ease-out; }
.anim-play { animation: cardPlay 0.3s ease-in forwards; }
.anim-buy { animation: cardBuy 0.3s ease-out; }
.anim-market-in { animation: marketSlideIn 0.35s ease-out; }
.anim-shake { animation: damageShake 0.4s ease; }
.anim-glory-pulse { animation: gloryPulse 0.4s ease; }
.anim-glory-damage { animation: gloryDamage 0.5s ease; }
.anim-stronghold-destroy { animation: strongholdDestroy 0.4s ease forwards; }
.anim-offer { animation: offerGlow 0.5s ease forwards; }
.anim-harmony { animation: harmonyPulse 0.6s ease; }
.anim-fade-in { animation: fadeIn 0.3s ease; }

/* ═══════════════════════════════════════════════
   RESPONSIVE — TABLET (< 900px)
   ═══════════════════════════════════════════════ */

@media (max-width: 900px) {
  .card { min-width: 140px; max-width: 140px; }
  .resources-bar { gap: 12px; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — PHONE (< 600px)
   ═══════════════════════════════════════════════ */

@media (max-width: 600px) {
  #game-container { padding: 4px; padding-bottom: 90px; }

  .card {
    min-width: 125px;
    max-width: 125px;
    padding: 6px;
  }

  .card-art { height: 55px; }
  .card-name { font-size: 0.68rem; }
  .card-text { font-size: 0.6rem; }
  .card-flavor { font-size: 0.55rem; }

  .opponent-area {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .glory-number { font-size: 1.2rem; }
  .resource-value { font-size: 1.1rem; }
  .resources-bar { gap: 10px; padding: 6px 8px; }

  .actions-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    padding: 8px 12px;
    border-top: 1px solid #222;
    z-index: 50;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .actions-bar .btn { padding: 8px 12px; font-size: 0.7rem; white-space: nowrap; }
  .log-area { max-height: 80px; }

  .card-detail { padding: 16px; max-width: 95vw; }
  .card-detail .detail-art { height: 90px; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — SMALL PHONE (< 400px)
   ═══════════════════════════════════════════════ */

@media (max-width: 400px) {
  .card { min-width: 110px; max-width: 110px; }
  .card-art { height: 45px; }
  .card-flavor { display: none; }
  .card-verse { display: none; }
  .actions-bar .btn { padding: 6px 10px; font-size: 0.65rem; }
}

/* ─── TOUCH DEVICES ─── */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: none; }
  .card:active { transform: scale(0.97); }
  .stronghold-mini:hover { transform: none; }
  .stronghold-mini:active { transform: scale(0.97); }
}
