/* Custom Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-forest-bg: radial-gradient(circle at center, #0b2e16 0%, #031207 70%, #000201 100%);
  --color-parchment: #f4ebd0;
  --color-parchment-dark: #e6d5b3;
  --color-wood-dark: #3a2215;
  --color-wood-light: #5c3b25;
  --color-gold: #ffd700;
  --color-gold-dull: #d4af37;
  --color-emerald: #10b981;
  --color-emerald-glow: rgba(16, 185, 129, 0.6);
  --color-crimson: #991b1b;
  --font-header: 'MedievalSharp', cursive, serif;
  --font-body: 'Crimson Pro', Georgia, serif;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-forest-bg);
  font-family: var(--font-body);
  color: #f5ebe0;
  padding: 10px;
  overflow: hidden; /* Avoid scrollbars on itch.io embeds */
}

/* Container Wrapper */
.wrapper {
  width: 100%;
  max-width: 960px;
  max-height: 98vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px;
  align-items: center;
  justify-content: center;
}

/* Parchment HUD Styling */
.parchment-hud {
  width: 100%;
  max-width: 560px;
  background: var(--color-parchment);
  color: var(--color-wood-dark);
  padding: 10px 16px;
  border-radius: 12px;
  border: 4px double var(--color-wood-dark);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), inset 0 0 15px rgba(58, 34, 21, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: var(--font-header);
}

/* Tamer Profile */
.tamer-profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tamer-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  background: var(--color-wood-dark);
  border-radius: 50%;
  border: 2px solid var(--color-gold-dull);
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.tamer-avatar .hood {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #14532d; /* Forest Green hood */
  clip-path: polygon(50% 0%, 100% 40%, 100% 100%, 0% 100%, 0% 40%);
}

.tamer-avatar .face {
  position: absolute;
  top: 16px;
  left: 8px;
  width: 24px;
  height: 18px;
  background: #ffdbb5; /* Peach skin */
  border-radius: 3px;
}

.tamer-avatar .eye {
  position: absolute;
  top: 5px;
  width: 4px;
  height: 4px;
  background: #00ffff; /* Glowing cyan eyes */
  border-radius: 50%;
  box-shadow: 0 0 5px #00ffff;
  animation: eyePulse 1.5s infinite alternate;
}

.tamer-avatar .eye.left { left: 4px; }
.tamer-avatar .eye.right { right: 4px; }

@keyframes eyePulse {
  0% { box-shadow: 0 0 2px #00ffff; }
  100% { box-shadow: 0 0 7px #00ffff; }
}

.tamer-stats {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tamer-name {
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
}

.tamer-xp-container {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.xp-bar-bg {
  width: 50px;
  height: 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
  border: 1px solid var(--color-wood-light);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: var(--color-gold);
  box-shadow: 0 0 4px var(--color-gold);
  transition: width 0.3s ease;
}

/* Stage Info */
.stage-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  text-align: center;
}

.stage-name {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--color-wood-dark);
}

.energy-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  width: 100%;
  justify-content: center;
}

.energy-bar-bg {
  width: 80px;
  height: 10px;
  background: rgba(58, 34, 21, 0.2);
  border-radius: 5px;
  border: 1.5px solid var(--color-wood-light);
  overflow: hidden;
}

.energy-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #10b981, #34d399);
  box-shadow: 0 0 6px var(--color-emerald);
  width: 0%;
  transition: width 0.3s ease;
}

.energy-text {
  font-size: 0.75rem;
  font-weight: bold;
}

/* Tamer Resources */
.tamer-resources {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
}

.hearts-container {
  color: var(--color-crimson);
  text-shadow: 0 0 2px rgba(255,255,255,0.8);
  font-size: 0.95rem;
}

.talisman-counter {
  font-weight: bold;
  color: #7c3aed;
  text-shadow: 0 0 4px rgba(124, 58, 237, 0.3);
}

.hud-label {
  font-size: 0.7rem;
  opacity: 0.8;
  text-transform: uppercase;
}

/* Game Canvas & Overlay Containers */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.canvas-wrapper {
  position: relative;
  border-radius: 12px;
  border: 6px double var(--color-gold-dull);
  background: #020703;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(16, 185, 129, 0.15);
  overflow: hidden;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 560/620; /* Dynamic scaling */
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Narrative Dialogue Overlay */
.dialogue-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 75%, rgba(0,0,0,0));
  padding: 12px;
  z-index: 10;
  display: flex;
  justify-content: center;
}

.dialogue-box {
  background: var(--color-parchment);
  color: var(--color-wood-dark);
  border: 3px double var(--color-wood-light);
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  display: flex;
  gap: 12px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  position: relative;
}

.dialogue-box::before {
  content: '';
  position: absolute;
  top: -4px; left: -4px; right: -4px; bottom: -4px;
  border: 1px solid var(--color-gold-dull);
  border-radius: 12px;
  pointer-events: none;
}

.speaker-avatar {
  width: 48px;
  height: 48px;
  background: var(--color-wood-dark);
  border-radius: 8px;
  border: 2px solid var(--color-gold-dull);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.speaker-hood {
  background: #15803d !important;
}

.dialogue-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.dialogue-speaker {
  font-family: var(--font-header);
  font-size: 0.95rem;
  color: var(--color-wood-light);
  border-bottom: 1px solid rgba(58, 34, 21, 0.2);
  padding-bottom: 1px;
  margin-bottom: 4px;
}

.dialogue-text {
  font-size: 0.9rem;
  line-height: 1.35;
  margin-bottom: 6px;
  min-height: 36px;
}

.dialogue-footer {
  display: flex;
  justify-content: flex-end;
}

/* Status Screen Overlay (Start/Game Over) */
.status-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 5, 2, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(3px);
}

.status-box {
  background: var(--color-parchment);
  color: var(--color-wood-dark);
  border: 4px double var(--color-wood-dark);
  border-radius: 14px;
  padding: 24px;
  width: 85%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  font-family: var(--font-header);
}

.status-title {
  font-size: 1.8rem;
  color: #1b4d24;
  text-shadow: 1px 1px 0px var(--color-gold), 2px 2px 6px rgba(0,0,0,0.3);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.status-desc {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  margin-bottom: 16px;
  color: #4b3621;
}

/* Fantasy Buttons */
.fantasy-btn {
  background: linear-gradient(to bottom, var(--color-wood-light), var(--color-wood-dark));
  color: var(--color-parchment);
  font-family: var(--font-header);
  border: 2px solid var(--color-gold-dull);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 3px 5px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  text-shadow: 1px 1px 1px rgba(0,0,0,0.8);
  transition: all 0.15s ease;
}

.fantasy-btn:hover {
  background: linear-gradient(to bottom, #724c33, #4e3020);
  border-color: var(--color-gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4), 0 0 6px rgba(255, 215, 0, 0.3);
}

.fantasy-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.start-btn {
  padding: 10px 24px;
  font-size: 1.1rem;
  background: linear-gradient(to bottom, #1e5a2c, #0f3619);
  border-color: #34d399;
}

.start-btn:hover {
  background: linear-gradient(to bottom, #2d8243, #154c25);
  border-color: #6ee7b7;
  box-shadow: 0 5px 12px rgba(16, 185, 129, 0.3);
}

/* Action Bar below Canvas */
.action-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
}

.hint {
  font-size: 0.8rem;
  opacity: 0.75;
  text-align: center;
  max-width: 500px;
  line-height: 1.3;
}

.hint strong {
  color: var(--color-gold);
}

/* Bestiary Modal */
.journal-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.journal-box {
  background: var(--color-parchment);
  color: var(--color-wood-dark);
  border: 5px double var(--color-wood-dark);
  border-radius: 12px;
  width: 90%;
  max-width: 460px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
}

.journal-header {
  padding: 12px 16px;
  border-bottom: 2px solid rgba(58, 34, 21, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-header);
}

.journal-header h2 {
  font-size: 1.3rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--color-wood-light);
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--color-crimson);
}

.journal-content {
  padding: 14px;
  overflow-y: auto;
  flex-grow: 1;
}

.bestiary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Bestiary Entry */
.bestiary-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--color-parchment-dark);
  border-radius: 8px;
  border: 1px solid rgba(58, 34, 21, 0.15);
}

.bestiary-entry.locked {
  opacity: 0.6;
  filter: grayscale(1);
}

.monster-icon-container {
  width: 38px;
  height: 38px;
  background: var(--color-wood-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 1.5px solid var(--color-gold-dull);
  flex-shrink: 0;
}

.monster-details {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.monster-name {
  font-family: var(--font-header);
  font-weight: bold;
  font-size: 0.95rem;
}

.monster-desc {
  font-size: 0.8rem;
  line-height: 1.25;
  color: #4b3621;
}

.monster-status {
  margin-left: auto;
  font-family: var(--font-header);
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--color-wood-light);
  color: var(--color-parchment);
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.monster-status.captured {
  background: #15803d;
}

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

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-3px, 1px); }
  20%, 40%, 60%, 80% { transform: translate(3px, -1px); }
}

.shake {
  animation: shake 0.4s ease;
}

/* ==========================================================================
   LANDSCAPE LAYOUT (Best for Itch.io default embedding ratios like 800x600 / 960x640)
   ========================================================================== */
@media (min-width: 800px) and (min-height: 520px) {
  body {
    padding: 15px;
  }

  .wrapper {
    flex-direction: row;
    align-items: stretch;
    width: 840px;
    height: 94vh;
    max-height: 640px;
    gap: 16px;
  }

  /* HUD turns into a vertical sidebar */
  .parchment-hud {
    width: 230px;
    height: 100%;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 20px 14px;
    gap: 12px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
  }

  .tamer-profile {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    width: 100%;
    border-bottom: 2px solid rgba(58, 34, 21, 0.15);
    padding-bottom: 12px;
  }

  .tamer-avatar {
    width: 56px;
    height: 56px;
  }

  .tamer-avatar .face {
    top: 22px;
    left: 12px;
    width: 28px;
    height: 22px;
  }

  .tamer-xp-container {
    justify-content: center;
    font-size: 0.8rem;
  }

  .xp-bar-bg {
    width: 80px;
  }

  .stage-info {
    width: 100%;
    border-bottom: 2px solid rgba(58, 34, 21, 0.15);
    padding-bottom: 12px;
    gap: 6px;
  }

  .stage-name {
    font-size: 1.1rem;
    line-height: 1.3;
  }

  .energy-meter {
    flex-direction: column;
    gap: 4px;
  }

  .energy-bar-bg {
    width: 100%;
    max-width: 160px;
    height: 12px;
  }

  .tamer-resources {
    width: 100%;
    align-items: center;
    gap: 8px;
  }

  .resource-item {
    width: 100%;
    justify-content: space-between;
    font-size: 0.9rem;
    border-bottom: 1px dashed rgba(58, 34, 21, 0.1);
    padding-bottom: 4px;
  }

  /* Game main panel layout */
  .game-container {
    flex-grow: 1;
    height: 100%;
    justify-content: space-between;
    align-items: center;
  }

  .canvas-wrapper {
    height: calc(100% - 70px);
    width: auto;
    max-width: 100%;
  }

  .action-bar {
    margin-top: auto;
  }
}

/* Credits Modal custom styling */
.credits-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
}

.credits-photo {
  width: 140px;
  height: 190px;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid var(--color-gold-dull);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.credits-name {
  font-family: var(--font-header);
  font-size: 1.35rem;
  color: var(--color-wood-dark);
  font-weight: bold;
}

.credits-role {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--color-wood-light);
}

.credits-email-link {
  font-size: 0.9rem;
  font-weight: bold;
}

.credits-email-link a {
  color: #1d4ed8;
  text-decoration: none;
  border-bottom: 1px dashed #1d4ed8;
}

.credits-email-link a:hover {
  color: #1e40af;
}

.credits-assignment {
  font-size: 0.85rem;
  color: #4b3621;
  border-top: 1.5px dashed rgba(58, 34, 21, 0.2);
  padding-top: 8px;
  margin-top: 4px;
  line-height: 1.45;
}

