/* ============================================================
   style.css — Mothlight XII visual design
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0a0a12;
  font-family: 'Press Start 2P', monospace;
  color: #e8e0d4;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: default;
}

#game-container {
  position: relative;
  width: 100vw; height: 100vh;
  overflow: hidden;
}

/* ---- Canvas ---- */
#canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}

/* ---- CRT Scanline Overlay ---- */
#crt-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.12) 0px,
    rgba(0,0,0,0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}
#crt-overlay::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%);
}

/* ---- Top Buttons ---- */
#top-buttons {
  position: fixed;
  top: 8px; right: 8px;
  z-index: 200;
  display: flex;
  gap: 8px;
}
#fullscreen-btn, #mute-btn {
  width: 36px; height: 36px;
  background: rgba(26,26,46,0.8);
  border: 1px solid #3a3840;
  border-radius: 4px;
  color: #e8e0d4;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
#fullscreen-btn:hover, #mute-btn:hover {
  background: rgba(60,60,80,0.9);
  border-color: #d4a574;
}

/* ---- Screens ---- */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ---- Main Menu ---- */
#menu-screen {
  background: rgba(10,10,18,0.85);
  gap: 20px;
}
#title-area {
  text-align: center;
  margin-bottom: 20px;
}
#game-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(28px, 6vw, 64px);
  font-weight: 900;
  color: #d4a574;
  text-shadow:
    0 0 20px rgba(212,165,116,0.5),
    0 0 40px rgba(212,165,116,0.3),
    0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 0.15em;
  animation: titleGlow 4s ease-in-out infinite alternate;
}
.title-xii {
  color: #c77dff;
  text-shadow:
    0 0 20px rgba(199,125,255,0.6),
    0 0 40px rgba(199,125,255,0.3);
}
@keyframes titleGlow {
  0% { text-shadow: 0 0 20px rgba(212,165,116,0.4), 0 0 40px rgba(212,165,116,0.2), 0 2px 4px rgba(0,0,0,0.8); }
  100% { text-shadow: 0 0 30px rgba(212,165,116,0.7), 0 0 60px rgba(212,165,116,0.4), 0 2px 4px rgba(0,0,0,0.8); }
}
#title-subtitle {
  font-family: 'Cinzel', serif;
  font-size: clamp(10px, 1.8vw, 16px);
  color: #888;
  margin-top: 8px;
  letter-spacing: 0.2em;
}
#menu-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
}
.menu-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 1.4vw, 13px);
  padding: 12px 24px;
  background: rgba(26,26,46,0.9);
  border: 1px solid #3a3840;
  color: #e8e0d4;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.menu-btn:hover, .menu-btn.selected {
  background: rgba(50,50,70,0.9);
  border-left-color: #d4a574;
  color: #d4a574;
  transform: translateX(4px);
}
#menu-footer {
  font-size: 9px;
  color: #555;
  margin-top: 30px;
  text-align: center;
}

/* ---- Combat UI ---- */
#combat-ui {
  justify-content: space-between;
  padding: 10px;
  pointer-events: none;
}
#combat-ui > * { pointer-events: auto; }

#top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(10,10,18,0.85);
  border: 1px solid #2a2a3e;
  border-radius: 4px;
  font-size: clamp(8px, 1.2vw, 12px);
  flex-wrap: wrap;
  gap: 6px;
}
#player-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
#dignity-display { color: #e74c3c; }
#block-display { color: #4ecdc4; }
#candle-display { color: #f4a261; }
#gold-display { color: #d4a574; }
#mothlight-progress {
  color: #c77dff;
  font-family: 'Cinzel', serif;
  font-size: clamp(10px, 1.4vw, 14px);
}
.status-display {
  width: 100%;
  font-size: 8px;
  color: #c77dff;
  padding: 2px 0;
}

#customer-info {
  text-align: center;
  padding: 8px 16px;
  background: rgba(10,10,18,0.8);
  border: 1px solid #2a2a3e;
  border-radius: 4px;
  min-width: 200px;
  max-width: 400px;
}
#customer-name {
  font-family: 'Cinzel', serif;
  font-size: clamp(14px, 2vw, 20px);
  color: #d4a574;
  margin-bottom: 6px;
}
#customer-hp-bar {
  width: 100%;
  height: 12px;
  background: #1a0a0a;
  border: 1px solid #3a2020;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
#customer-hp-fill {
  height: 100%;
  background: #6bba62;
  transition: width 0.3s ease;
  border-radius: 1px;
}
#customer-hp-text {
  font-size: 8px;
  color: #888;
  margin-bottom: 4px;
}
#customer-intent {
  font-size: clamp(8px, 1.1vw, 11px);
  color: #e74c3c;
  margin-top: 4px;
}
#customer-statuses {
  font-size: 8px;
  color: #f4a261;
  margin-top: 2px;
}

#hand-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#pile-counts {
  font-size: 8px;
  color: #666;
  display: flex;
  gap: 20px;
}
#hand {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  padding: 4px;
  -webkit-overflow-scrolling: touch;
}
#end-turn-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 1.3vw, 13px);
  padding: 12px 32px;
  background: rgba(100,26,26,0.8);
  border: 2px solid #e74c3c;
  color: #e8e0d4;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  margin-top: 4px;
}
#end-turn-btn:hover {
  background: rgba(150,36,36,0.9);
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(231,76,60,0.4);
}
#end-turn-btn:active { transform: scale(0.95); }

/* ---- Cards ---- */
.card {
  position: relative;
  width: clamp(100px, 15vw, 140px);
  min-width: 90px;
  background: rgba(20,18,30,0.95);
  border: 2px solid #3a3840;
  border-top: 4px solid #d4a574;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.card:hover {
  transform: translateY(-12px) scale(1.05);
  box-shadow: 0 8px 20px rgba(0,0,0,0.6), 0 0 15px rgba(212,165,116,0.2);
  z-index: 5;
}
.card:active {
  transform: translateY(-4px) scale(0.98);
}
.card.unplayable {
  opacity: 0.45;
  filter: grayscale(0.5);
}
.card.unplayable:hover {
  transform: none;
  box-shadow: none;
}
.card.unaffordable {
  opacity: 0.5;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: clamp(8px, 1vw, 10px);
}
.card-cost {
  color: #f4a261;
  font-weight: bold;
}
.card-type-label {
  font-size: 7px;
  color: #666;
  text-transform: uppercase;
}
.card-name {
  font-size: clamp(7px, 1vw, 10px);
  color: #d4a574;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  line-height: 1.3;
  min-height: 2em;
}
.card-desc {
  font-size: clamp(6px, 0.9vw, 9px);
  color: #b8b0a4;
  line-height: 1.4;
  flex: 1;
}
.card-rarity {
  font-size: 7px;
  text-align: right;
}
.card-price {
  position: absolute;
  bottom: 4px; right: 6px;
  font-size: 8px;
  color: #d4a574;
  background: rgba(0,0,0,0.5);
  padding: 2px 4px;
  border-radius: 2px;
}

/* Card type colors */
.card-artifact { border-top-color: #f4a261; }
.card-ritual { border-top-color: #4ecdc4; }
.card-bargain { border-top-color: #e74c3c; }
.card-heirloom { border-top-color: #c77dff; }
.card-curse { border-top-color: #8b0000; opacity: 0.6; }

/* ---- Card Row (reward/shop) ---- */
.card-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 16px 0;
}
.card-row .card {
  cursor: pointer;
}

/* ---- Screen Titles ---- */
.screen-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(18px, 3vw, 28px);
  color: #d4a574;
  text-shadow: 0 0 20px rgba(212,165,116,0.4);
  margin-bottom: 8px;
  text-align: center;
}
.screen-subtitle {
  font-size: clamp(8px, 1.2vw, 11px);
  color: #888;
  margin-bottom: 8px;
  text-align: center;
}

/* ---- Action Buttons ---- */
.action-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 1.2vw, 12px);
  padding: 10px 24px;
  background: rgba(26,26,46,0.9);
  border: 2px solid #d4a574;
  color: #d4a574;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  margin: 4px;
}
.action-btn:hover {
  background: rgba(50,50,70,0.9);
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(212,165,116,0.3);
}
.action-btn.secondary {
  border-color: #666;
  color: #888;
}
.action-btn.secondary:hover {
  border-color: #888;
  color: #aaa;
}
.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- Reward / Shop / etc ---- */
#reward-screen { background: rgba(10,10,18,0.9); gap: 8px; }
#shop-screen { background: rgba(10,10,18,0.9); gap: 8px; }
#remove-screen { background: rgba(10,10,18,0.92); gap: 8px; }
#shop-services { display: flex; gap: 8px; margin: 8px 0; }

/* ---- Game Over / Victory ---- */
#gameover-screen { background: rgba(10,5,5,0.92); gap: 10px; }
#gameover-screen .screen-title { color: #e74c3c; text-shadow: 0 0 20px rgba(231,76,60,0.4); }
#gameover-text { font-size: clamp(8px, 1.2vw, 12px); color: #b8a8a0; text-align: center; max-width: 400px; }
#victory-screen { background: rgba(10,10,18,0.92); gap: 10px; }
#victory-screen .screen-title { color: #d4a574; text-shadow: 0 0 30px rgba(212,165,116,0.6); }
#victory-text { font-size: clamp(8px, 1.2vw, 12px); color: #d4c8b0; text-align: center; max-width: 500px; }

.stats-display {
  font-size: 10px;
  color: #888;
  text-align: center;
  padding: 8px;
  border: 1px solid #2a2a3e;
  border-radius: 4px;
  background: rgba(20,18,30,0.5);
}

#initials-entry, #victory-initials {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#initials-entry p, #victory-initials p {
  font-size: 10px;
  color: #888;
}
input[type="text"] {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  width: 80px;
  text-align: center;
  background: rgba(20,18,30,0.9);
  border: 2px solid #d4a574;
  color: #d4a574;
  padding: 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 4px;
}
input[type="text"]:focus {
  outline: none;
  box-shadow: 0 0 10px rgba(212,165,116,0.3);
}

/* ---- Leaderboard ---- */
#leaderboard-screen { background: rgba(10,10,18,0.92); gap: 10px; }
#leaderboard-list {
  max-height: 50vh;
  overflow-y: auto;
  width: 100%;
  max-width: 500px;
}
#leaderboard-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(7px, 1vw, 10px);
}
#leaderboard-list th {
  color: #d4a574;
  padding: 6px 8px;
  border-bottom: 1px solid #3a3840;
  text-align: left;
}
#leaderboard-list td {
  padding: 6px 8px;
  border-bottom: 1px solid #1a1a2e;
  color: #b8b0a4;
}
#leaderboard-list tr:hover td {
  background: rgba(50,50,70,0.3);
}

/* ---- Tutorial ---- */
#tutorial-screen { background: rgba(10,10,18,0.92); gap: 12px; }
#tutorial-content {
  max-width: 500px;
  text-align: center;
}
#tutorial-content h2 {
  font-family: 'Cinzel', serif;
  font-size: clamp(16px, 2.5vw, 22px);
  color: #d4a574;
  margin-bottom: 12px;
}
#tutorial-content p {
  font-size: clamp(8px, 1.2vw, 11px);
  color: #b8b0a4;
  line-height: 1.7;
}
#tutorial-buttons {
  display: flex;
  gap: 8px;
}

/* ---- Settings ---- */
#settings-screen { background: rgba(10,10,18,0.92); gap: 14px; }
.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(8px, 1.2vw, 11px);
}
.settings-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #b8b0a4;
}
input[type="range"] {
  width: 120px;
  accent-color: #d4a574;
}
select {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: rgba(20,18,30,0.9);
  border: 1px solid #3a3840;
  color: #e8e0d4;
  padding: 4px 8px;
  border-radius: 3px;
}

/* ---- Pause ---- */
#pause-screen { background: rgba(10,10,18,0.85); gap: 16px; z-index: 50; }
#pause-buttons { display: flex; flex-direction: column; gap: 10px; }

/* ---- Demo Overlay ---- */
#demo-overlay {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-size: clamp(10px, 1.5vw, 14px);
  color: #d4a574;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  font-size: clamp(8px, 1.1vw, 11px);
  color: #e8e0d4;
  background: rgba(26,26,46,0.9);
  border: 1px solid #3a3840;
  padding: 6px 16px;
  border-radius: 4px;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
  .card {
    width: clamp(80px, 22vw, 110px);
    min-width: 75px;
    padding: 5px;
    gap: 2px;
  }
  .card-desc { font-size: 6px; }
  .card-name { font-size: 7px; }
  #hand { gap: 3px; }
  #end-turn-btn {
    padding: 10px 20px;
    font-size: 10px;
  }
  #top-bar { font-size: 8px; padding: 4px 8px; }
  .card-row { gap: 6px; }
}

@media (max-width: 480px) {
  .card {
    width: clamp(70px, 26vw, 95px);
    min-width: 65px;
    padding: 4px;
    border-width: 1px;
    border-top-width: 3px;
  }
  .card-header { font-size: 7px; }
  .card-name { font-size: 6px; min-height: 1.5em; }
  .card-desc { font-size: 5px; line-height: 1.3; }
  #hand { gap: 2px; padding: 2px; }
  #end-turn-btn { padding: 8px 16px; font-size: 9px; }
  .screen-title { font-size: 16px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0a0a12; }
::-webkit-scrollbar-thumb { background: #3a3840; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4850; }

/* ---- Fullscreen cursor hide ---- */
:fullscreen #top-buttons {
  opacity: 0.3;
  transition: opacity 0.5s;
}
:fullscreen:hover #top-buttons {
  opacity: 1;
}
