/**
 * Gold and Ghouls - Game Styles
 * A daily puzzle game combining Wordle-style deduction with dungeon crawling.
 * 
 * Copyright 2025 DTerm Limited
 * Concept, code, music: Phil Gooch
 * Tile art: Dom Wright
 */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  background: #1c1917;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #d6d3d1;
}

h1 {
  color: #f59e0b;
  margin: 0 0 8px 0;
  font-size: 1.75rem;
}

.stats-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.level-info {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #a8a29e;
}

.stat-value {
  font-weight: bold;
}

.hearts {
  display: flex;
  gap: 2px;
}

.heart {
  font-size: 1.25rem;
}

.heart.filled {
  color: #ef4444;
}

.heart.empty {
  color: #57534e;
}

.key-icon {
  font-size: 1.1rem;
}

.key-icon.found {
  color: #facc15;
}

.key-icon.missing {
  color: #57534e;
}

.loot-value {
  color: #fbbf24;
}

.total-value {
  color: #f59e0b;
}

.message {
  height: 24px;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 12px;
  text-align: center;
  padding: 0 8px;
}

.message.neutral { color: #d6d3d1; }
.message.danger { color: #f87171; }
.message.success { color: #4ade80; }
.message.treasure { color: #fbbf24; }
.message.key { color: #fde047; }

.game-grid {
  display: flex;
  flex-direction: column;
}

.col-clues {
  display: flex;
  margin-left: 50px;
}

.row {
  display: flex;
  align-items: center;
}

/* Clue tiles - using image backgrounds for numbered clues */
.clue {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: bold;
  color: #e7e5e4;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Fallback background colour for clue 0 (no image) */
.clue-0 { background-image: url('images/Dungeon_0.png'); }
.clue-1 { background-image: url('images/Dungeon_1.png'); }
.clue-2 { background-image: url('images/Dungeon_2.png'); }
.clue-3 { background-image: url('images/Dungeon_3.png'); }
.clue-4 { background-image: url('images/Dungeon_4.png'); }
.clue-5 { background-image: url('images/Dungeon_5.png'); }
.clue-6 { background-image: url('images/Dungeon_6.png'); }
.clue-7 { background-image: url('images/Dungeon_7.png'); }
.clue-8 { background-image: url('images/Dungeon_8.png'); }
.clue-9 { background-image: url('images/Dungeon_9.png'); }

/* Base tile styles */
.tile {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease;
  user-select: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Hidden/unrevealed tile */
.tile.hidden {
  background-image: url('images/Dungeon_back.png');
}

.tile.hidden:active {
  filter: brightness(1.2);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* Floor/empty tile */
.tile.floor {
  background-image: url('images/Dungeon_empty.png');
  cursor: default;
}

/* Trap tile */
.tile.trap {
  background-image: url('images/Dungeon_trap.png');
  cursor: default;
}

/* Chest states */
.tile.chest {
  background-image: url('images/Dungeon_chest_closed.png');
  cursor: pointer;
}

.tile.chest-open {
  background-image: url('images/Dungeon_chest_open.png');
  cursor: default;
}

/* Key tile (revealed from chest) */
.tile.key {
  background-image: url('images/Dungeon_key.png');
  cursor: default;
}

/* Door states */
.tile.door-locked {
  background-image: url('images/Dungeon_door_closed.png');
  cursor: default;
}

.tile.door-open {
  background-image: url('images/Dungeon_door_open.png');
  cursor: pointer;
}

.tile.door-open:active {
  filter: brightness(1.1);
}

/* Potion tile */
.tile.potion {
  background-image: url('images/Dungeon_potion.png');
  cursor: default;
}

/* Amulet tile */
.tile.amulet {
  background-image: url('images/Dungeon_amulet.png');
  cursor: default;
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from { box-shadow: 0 0 4px #fbbf24; }
  to { box-shadow: 0 0 12px #fbbf24; }
}

/* Armour/shield tile */
.tile.armour {
  background-image: url('images/Dungeon_shield.png');
  cursor: default;
}

/* Coins/loot tile */
.tile.coins {
  background-image: url('images/Dungeon_loot.png');
  cursor: default;
}

/* Ghoul/demon tile */
.tile.ghoul {
  background-image: url('images/Dungeon_demon.png');
  cursor: default;
}

.tile.ghoul.combat {
  cursor: pointer;
  animation: ghoulPulse 0.5s ease-in-out infinite alternate;
}

@keyframes ghoulPulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.3); }
}

/* Merchant tile */
.tile.merchant {
  background-image: url('images/Dungeon_merchant.png');
  cursor: pointer;
}

.tile.merchant:active {
  filter: brightness(1.1);
}

/* Pathfinder mode styles */
.tile.player-here {
  box-shadow: 0 0 0 3px #fbbf24, 0 0 12px #fbbf24;
  z-index: 10;
  position: relative;
}

.tile.player-here::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #fbbf24;
  border-radius: 50%;
  box-shadow: 0 0 4px #fbbf24;
}

.tile.start-tile {
  opacity: 0.7;
}

.tile.start-tile::before {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 8px;
  height: 8px;
  background: #60a5fa;
  border-radius: 50%;
}

.tile.reachable {
  box-shadow: 0 0 0 2px #4ade80;
  animation: pulse-reachable 1.5s ease-in-out infinite;
}

.tile.hidden.reachable {
  cursor: pointer;
}

@keyframes pulse-reachable {
  0%, 100% { box-shadow: 0 0 0 2px #4ade80; }
  50% { box-shadow: 0 0 0 2px #4ade80, 0 0 8px #4ade80; }
}

/* Chest opening animation */
.tile.chest-opening {
  animation: chestOpen 0.3s ease-out forwards;
}

@keyframes chestOpen {
  0% { 
    background-image: url('images/Dungeon_chest_closed.png');
    transform: scale(1);
  }
  50% { 
    transform: scale(1.1);
  }
  100% { 
    background-image: url('images/Dungeon_chest_open.png');
    transform: scale(1);
  }
}

.legend {
  margin-top: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: #d6d3d1;
  line-height: 1.6;
}

.buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

button {
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-next {
  background: #15803d;
  color: white;
}

.btn-next:active {
  background: #16a34a;
}

.btn-new {
  background: #44403c;
  color: #e7e5e4;
}

.btn-new:active {
  background: #57534e;
}

.btn-try-again {
  background: #15803d;
  color: #e7e5e4;
}

.btn-try-again:active {
  background: #166534;
}

.btn-rules {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #57534e;
  color: #d6d3d1;
}

.btn-rules:active {
  background: #78716c;
}

.footer-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

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

.modal {
  background: #292524;
  border-radius: 12px;
  padding: 20px;
  max-width: 320px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 2px solid #57534e;
}

.modal h2 {
  color: #f59e0b;
  margin: 0 0 12px 0;
  font-size: 1.25rem;
}

.modal h3 {
  color: #a8a29e;
  margin: 16px 0 8px 0;
  font-size: 1rem;
}

.modal ul {
  margin: 0;
  padding-left: 20px;
  color: #d6d3d1;
}

.modal li {
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.modal p {
  margin: 6px 0;
  font-size: 0.85rem;
}

.btn-close {
  margin-top: 16px;
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #15803d;
  color: white;
}

.btn-close:active {
  background: #16a34a;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-yes, .btn-no {
  flex: 1;
  padding: 10px;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.btn-yes {
  background: #dc2626;
  color: white;
}

.btn-yes:active {
  background: #ef4444;
}

.btn-no {
  background: #57534e;
  color: #d6d3d1;
}

.btn-no:active {
  background: #78716c;
}

/* Links */
a {
  color: #8888cc;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #c9a227;
}

.site-footer {
  margin-top: auto;
  padding: 20px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: #78716c;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 640px) {
  .site-footer {
    font-size: 0.8rem;
    padding: 24px 16px;
  }
}
