* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  font-family: 'Courier New', monospace;
  background: #1a1a1a;
  color: #f0f0f0;
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  padding: 20px;
}

/* ── Realm Selector ── */
.realm-selector {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 20px;
}

.realm-selector h1 {
  font-size: 3em;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  letter-spacing: 2px;
}

.realm-selector p {
  font-size: 1.2em;
  margin-bottom: 40px;
  color: #aaa;
}

.realm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.realm-btn {
  padding: 30px 20px;
  border: 3px solid;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 1.1em;
  cursor: pointer;
  transition: all 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  font-family: 'Courier New', monospace;
}

.realm-btn:hover {
  transform: scale(1.05);
  background: rgba(255,255,255,0.15);
  box-shadow: 0 0 20px rgba(255,255,255,0.3);
}

.realm-title {
  font-weight: bold;
  letter-spacing: 1px;
}

/* ── Game Container ── */
.game-container {
  max-width: 1200px;
  margin: 0 auto;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: rgba(0,0,0,0.3);
  border-left: 5px solid var(--theme-color);
  border-radius: 4px;
}

.game-header h2 {
  font-size: 2em;
  letter-spacing: 1px;
}

.quit-btn {
  padding: 10px 20px;
  background: rgba(231,76,60,0.8);
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Courier New', monospace;
  font-size: 1em;
}

.quit-btn:hover {
  background: rgba(231,76,60,1);
}

/* ── Layout ── */
.game-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
}

/* ── Status Panel ── */
.status-card {
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--theme-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 1.1em;
}

.status-row:last-child {
  border-bottom: none;
}

.hearts {
  letter-spacing: 4px;
  font-size: 1.1em;
}

.heart-full  { color: #e74c3c; }
.heart-empty { color: #444; }

.gem-count {
  color: #f1c40f;
  font-weight: bold;
  font-size: 1.3em;
}

/* ── Space Info Card ── */
.space-info-card {
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  font-weight: bold;
}

.space-info-card.has-monster {
  background: rgba(231,76,60,0.15);
  border: 2px solid #e74c3c;
}

.space-info-card.safe {
  background: rgba(39,174,96,0.15);
  border: 2px solid #27ae60;
}

.space-title {
  margin-bottom: 8px;
  font-size: 1.1em;
}

.space-info-card.has-monster .space-title { color: #e74c3c; }
.space-info-card.safe .space-title         { color: #27ae60; }

.monster-details {
  font-size: 0.85em;
  opacity: 0.9;
  margin-top: 5px;
  font-weight: normal;
}

/* ── Active Monster Card ── */
.monster-card {
  background: rgba(231,76,60,0.1);
  border: 2px solid #e74c3c;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.monster-card h3 {
  color: #e74c3c;
  margin-bottom: 10px;
}

.monster-health-text {
  margin-bottom: 8px;
  font-size: 0.9em;
}

.health-bar-visual {
  width: 100%;
  height: 20px;
  background: rgba(0,0,0,0.5);
  border: 1px solid #e74c3c;
  border-radius: 4px;
  overflow: hidden;
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, #e74c3c, #c0392b);
  transition: width 0.3s ease;
}

/* ── Dice Section ── */
.dice-section {
  text-align: center;
  padding: 40px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 2px dashed var(--theme-color);
  margin-bottom: 20px;
}

.roll-btn {
  font-size: 1.5em;
  padding: 20px 40px;
  background: var(--theme-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: bold;
  letter-spacing: 1px;
  font-family: 'Courier New', monospace;
}

.roll-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 0 30px var(--theme-color);
}

.roll-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.roll-btn.rolling {
  animation: pulse 0.4s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.05); }
}

.dice-display {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 30px;
  flex-wrap: wrap;
}

.dice-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dice-label {
  font-size: 0.9em;
  color: #aaa;
  margin-bottom: 4px;
}

.dice-pair {
  display: flex;
  gap: 10px;
}

.die {
  width: 50px;
  height: 50px;
  border: 3px solid var(--theme-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6em;
  font-weight: bold;
  background: rgba(0,0,0,0.5);
}

.die.rolling {
  animation: spin 0.3s linear infinite;
}

@keyframes spin {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(360deg); }
}

.action-btn {
  padding: 10px 24px;
  background: var(--theme-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
}

.action-btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.action-btn.skip {
  background: rgba(180,180,180,0.3);
  border: 1px solid #888;
  align-self: flex-end;
}

/* ── Board ── */
.board-container {
  overflow-x: auto;
  margin-bottom: 20px;
}

.board {
  position: relative;
  min-height: 120px;
  padding: 10px 0;
}

.board-spaces {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}

.board-space {
  width: 54px;
  height: 54px;
  border: 2px solid #555;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75em;
  font-weight: bold;
  background: rgba(255,255,255,0.05);
  transition: all 0.2s;
  position: relative;
  cursor: default;
  user-select: none;
}

.board-space.start-space {
  border-color: #aaa;
  background: rgba(255,255,255,0.1);
}

.board-space.boss-space {
  border-color: #e74c3c;
  background: rgba(231,76,60,0.1);
}

.board-space.current {
  border-color: var(--theme-color);
  background: rgba(255,255,255,0.2);
  box-shadow: 0 0 12px var(--theme-color);
}

.board-space.available {
  border-color: #2ecc71;
  background: rgba(46,204,113,0.15);
  cursor: pointer;
  animation: glow 1s infinite alternate;
}

@keyframes glow {
  from { box-shadow: 0 0 5px #2ecc71; }
  to   { box-shadow: 0 0 14px #2ecc71; }
}

.board-space.available:hover {
  background: rgba(46,204,113,0.3);
  transform: scale(1.08);
}

.board-space.cleared {
  border-color: #555;
  opacity: 0.6;
}

.space-icon {
  font-size: 1em;
  line-height: 1;
}

.space-label {
  font-size: 0.7em;
  color: #aaa;
}

/* ── Message Box ── */
.message-box {
  padding: 16px 20px;
  background: rgba(0,0,0,0.4);
  border-left: 4px solid var(--theme-color);
  border-radius: 4px;
  font-size: 1em;
  min-height: 54px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ── End States ── */
.game-over, .victory {
  padding: 24px;
  border-radius: 8px;
  text-align: center;
  font-size: 1.2em;
  margin-top: 16px;
}

.game-over {
  background: rgba(231,76,60,0.2);
  border: 2px solid #e74c3c;
}

.victory {
  background: rgba(241,196,15,0.15);
  border: 2px solid #f1c40f;
  color: #f1c40f;
}

.game-over button, .victory button {
  display: block;
  margin: 16px auto 0;
  padding: 12px 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 1em;
  background: var(--theme-color);
  color: white;
}

/* ── Phase Bar ── */
.phase-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 0.8em;
  color: #888;
}
.phase-step { opacity: 0.45; }
.phase-step.active { opacity: 1; color: var(--theme-color); font-weight: bold; }

/* ── Dice Section (compact variant) ── */
.dice-section.compact {
  padding: 16px 20px;
}

.dice-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.die.white { border-color: #eee; background: rgba(255,255,255,0.1); }
.die.black { border-color: #555; background: #1a1a1a; color: #f1c40f; }

/* ── Split Selector ── */
.split-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.split-option {
  padding: 10px 18px;
  background: rgba(255,255,255,0.08);
  border: 2px solid var(--theme-color);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 1em;
  transition: all 0.2s;
}
.split-option:hover { background: rgba(255,255,255,0.18); transform: translateY(-1px); }

/* ── Confirm / Black Die ── */
.pairs-display {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 12px;
}
.pair-box {
  padding: 10px 20px;
  border: 2px solid var(--theme-color);
  border-radius: 6px;
  font-size: 1.1em;
  font-weight: bold;
}
.black-die-section {
  background: rgba(241,196,15,0.1);
  border: 1px solid #f1c40f;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.black-die-section p { margin-bottom: 8px; font-size: 0.9em; color: #f1c40f; }
.black-swap-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.swap-btn {
  padding: 6px 12px;
  background: rgba(241,196,15,0.15);
  border: 1px solid #f1c40f;
  border-radius: 4px;
  color: #f1c40f;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  transition: all 0.2s;
}
.swap-btn:hover { background: rgba(241,196,15,0.3); }

/* ── Pair Assign Header ── */
.pair-assign-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1em;
  margin-bottom: 8px;
}

/* ── Monster Panel ── */
.monster-panel {
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--theme-color);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  max-height: 320px;
  overflow-y: auto;
}
.monster-panel h4 { margin-bottom: 8px; color: var(--theme-color); }
.monster-item {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85em;
}
.monster-item:last-child { border-bottom: none; }
.monster-item.defeated { opacity: 0.4; }
.monster-item.boss-monster { border: 1px solid #e74c3c; border-radius: 4px; padding: 8px; margin-bottom: 4px; background: rgba(231,76,60,0.05); }
.monster-name { font-weight: bold; margin-bottom: 3px; }
.monster-nums { color: #aaa; font-size: 0.85em; margin-bottom: 4px; }
.attack-btn {
  margin-top: 5px;
  padding: 4px 12px;
  background: rgba(231,76,60,0.8);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  transition: all 0.2s;
}
.attack-btn:hover { background: #e74c3c; }

/* ── Achievement Tracker ── */
.achievement-tracker {
  background: rgba(0,0,0,0.3);
  border: 1px solid #555;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.82em;
  margin-bottom: 12px;
}
.achievement-tracker h4 { margin-bottom: 6px; color: #aaa; }
.achievement-row { padding: 3px 0; color: #aaa; }
.achievement-row.done { color: #2ecc71; }

/* ── SVG Map ── */
.dungeon-map {
  width: 100%;
  height: auto;
  display: block;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}
.map-edge { stroke: #333; stroke-width: 2; }
.map-edge.visited { stroke: rgba(255,255,255,0.2); }

.space-node { fill: #2a2a2a; stroke: #555; stroke-width: 2; cursor: default; }
.space-node.start-node   { fill: #1a4a1a; stroke: #27ae60; stroke-width: 3; }
.space-node.fist-node    { fill: #3a2a0a; stroke: #e67e22; stroke-width: 2; }
.space-node.gold-node    { fill: #3a3a0a; stroke: #f1c40f; stroke-width: 2; }
.space-node.gem-node     { fill: #0a2a3a; stroke: #3498db; stroke-width: 2; }
.space-node.chest-node   { fill: #2a1a3a; stroke: #9b59b6; stroke-width: 2; }
.space-node.rubble-node  { fill: #2a1a0a; stroke: #795548; stroke-width: 2; }
.space-node.cloud-node   { fill: #1a2a3a; stroke: #8e9cc0; stroke-width: 2; }
.space-node.claw-node    { fill: #3a1a1a; stroke: #c0392b; stroke-width: 2; }
.space-node.worm-node    { fill: #1a2a1a; stroke: #27ae60; stroke-width: 2; }

.space-node.visited      { opacity: 0.5; }
.space-node.partial      { opacity: 0.8; stroke-dasharray: 4 2; }
.space-node.available    { stroke: #2ecc71; stroke-width: 3; cursor: pointer;
                           animation: mapglow 0.9s infinite alternate; }
@keyframes mapglow {
  from { filter: drop-shadow(0 0 4px #2ecc71); }
  to   { filter: drop-shadow(0 0 10px #2ecc71); }
}
.space-node.available:hover { fill: rgba(46,204,113,0.3); }

.space-label {
  text-anchor: middle;
  font-size: 10px;
  fill: #eee;
  pointer-events: none;
  font-family: 'Courier New', monospace;
  font-weight: bold;
}
.space-label.available-label { fill: #2ecc71; pointer-events: none; }

.monster-node         { fill: #2a0a0a; stroke: #e74c3c; stroke-width: 2; }
.monster-node.boss    { fill: #3a0a0a; stroke: #c0392b; stroke-width: 3; }
.monster-node.accessible { stroke: #e74c3c; stroke-width: 2; fill: #3a0a0a; }
.monster-node.defeated { fill: #1a1a1a; stroke: #555; opacity: 0.5; }
.monster-hp-fill      { fill: #e74c3c; }
.monster-label        { text-anchor: middle; font-size: 8px; fill: #eee; pointer-events: none; font-family: 'Courier New', monospace; }
.monster-access-line  { stroke: #555; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.4; }
.monster-access-line.accessible { stroke: #e74c3c; opacity: 0.7; }
.monster-access-line.defeated   { stroke: #555; opacity: 0.2; }

/* ── Cloud Setup ── */
.cloud-setup {
  background: rgba(0,0,0,0.3);
  border: 2px solid #8e9cc0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}
.cloud-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}
.cloud-space {
  width: 56px; height: 56px;
  border: 2px solid #8e9cc0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1em; font-weight: bold;
  cursor: pointer; background: #1a2a3a;
  position: relative; transition: all 0.2s;
}
.cloud-space:hover { border-color: #fff; }
.cloud-space.selected { border-color: #2ecc71; box-shadow: 0 0 10px #2ecc71; }
.cloud-space.assigned { border-color: #f1c40f; color: #f1c40f; }
.cloud-clear {
  position: absolute; top: -6px; right: -6px;
  background: #e74c3c; border: none; color: white;
  border-radius: 50%; width: 16px; height: 16px;
  font-size: 10px; cursor: pointer; line-height: 16px; text-align: center;
}
.cloud-pool { margin-bottom: 12px; }
.cloud-num-btn {
  margin: 4px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid #8e9cc0;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
}
.cloud-num-btn:hover { background: rgba(255,255,255,0.2); }
.cloud-num-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ── Treasure Chest Modal ── */
.chest-modal {
  background: rgba(155,89,182,0.15);
  border: 2px solid #9b59b6;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}
.chest-modal h3 { color: #9b59b6; margin-bottom: 12px; }
.chest-btn {
  display: block; width: 100%;
  margin: 8px 0;
  padding: 12px 16px;
  background: rgba(155,89,182,0.2);
  border: 1px solid #9b59b6;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
  text-align: left;
  transition: all 0.2s;
}
.chest-btn:hover { background: rgba(155,89,182,0.4); }

/* ── Responsive ── */
@media (max-width: 700px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

  .realm-selector h1 {
    font-size: 2em;
  }

  .dice-display {
    flex-direction: column;
    align-items: center;
  }

  .board-space {
    width: 44px;
    height: 44px;
    font-size: 0.65em;
  }
}
