* { box-sizing: border-box; }
html, body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0;
  background: #111;
  color: #eee;
  width: 100%;
  height: 100%;
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
}
.container {
  display: grid !important;
  grid-template-columns: 200px 1fr 200px !important;
  gap: 24px !important;
  align-items: start;
  width: 100%;
}
.sidebar {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px;
  position: sticky;
  top: 16px;
  width: 200px;
  grid-column: 1;
}
.character-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.character-image .character-name {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #eee;
  text-align: center;
}
.character-placeholder {
  width: 150px;
  height: 150px;
  background: #1b1b1b;
  border: 2px solid #333;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 0.9rem;
}

/* ZX81-style avatars: face only. Head = gradient, eyes = ::before + box-shadow (px offset so both eyes show), mouth = ::after. */
.avatar {
  width: 150px;
  height: 150px;
  background: #0a0a0a;
  border: 1px solid #1a3d1a;
  border-radius: 0;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar::before,
.avatar::after {
  content: "";
  position: absolute;
  background: #0a0a0a;
}
/* male_young: round face, two clear eyes (18px apart), smile mouth */
.avatar-male_young {
  background: radial-gradient(ellipse 44% 50% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-male_young::before {
  width: 12px;
  height: 10px;
  top: 38%;
  left: 38%;
  transform: translate(-50%, -50%);
  border-radius: 2px;
  box-shadow: 18px 0 0 0 #0a0a0a;
}
.avatar-male_young::after {
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 5px;
  border-radius: 2px;
}
/* male_old: narrower face, two eyes, heavy brow line, straight thin mouth */
.avatar-male_old {
  background: radial-gradient(ellipse 38% 44% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-male_old::before {
  width: 10px;
  height: 8px;
  top: 38%;
  left: 36%;
  transform: translate(-50%, -50%);
  border-radius: 0;
  box-shadow: 18px 0 0 0 #0a0a0a, 9px -14px 0 0 #0a0a0a;
}
.avatar-male_old::after {
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 0;
}
/* female_young: rounder softer face, bigger wider-set eyes, small smile */
.avatar-female_young {
  background: radial-gradient(ellipse 48% 54% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-female_young::before {
  width: 14px;
  height: 11px;
  top: 36%;
  left: 34%;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  box-shadow: 22px 0 0 0 #0a0a0a;
}
.avatar-female_young::after {
  top: 55%;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 4px;
  border-radius: 3px;
}
/* female_old: oval face, smaller eyes, thin line mouth */
.avatar-female_old {
  background: radial-gradient(ellipse 40% 46% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-female_old::before {
  width: 10px;
  height: 8px;
  top: 38%;
  left: 36%;
  transform: translate(-50%, -50%);
  border-radius: 1px;
  box-shadow: 18px 0 0 0 #0a0a0a;
}
.avatar-female_old::after {
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 0;
}
/* In 60px preview, scale face elements so two eyes and mouth fit */
.avatar-preview.avatar::before {
  transform: translate(-50%, -50%) scale(0.5);
  transform-origin: 50% 50%;
}
.avatar-preview.avatar-male_young::before,
.avatar-preview.avatar-female_young::before,
.avatar-preview.avatar-female_old::before {
  box-shadow: 9px 0 0 0 #0a0a0a;
}
.avatar-preview.avatar-male_old::before {
  box-shadow: 9px 0 0 0 #0a0a0a, 4px -7px 0 0 #0a0a0a;
}
.avatar-preview.avatar::after {
  transform: translateX(-50%) scale(0.5);
  transform-origin: 50% 50%;
}

/* Portrait mode: fantasy character images; gradient fallback if image fails to load */
.avatar-portrait.avatar::before,
.avatar-portrait.avatar::after {
  display: none;
}
.avatar-portrait.avatar-male_young {
  background: url("/static/avatars/male_young.png") center / cover no-repeat,
    radial-gradient(ellipse 44% 50% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-portrait.avatar-male_old {
  background: url("/static/avatars/male_old.png") center / cover no-repeat,
    radial-gradient(ellipse 38% 44% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-portrait.avatar-female_young {
  background: url("/static/avatars/female_young.png") center / cover no-repeat,
    radial-gradient(ellipse 48% 54% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-portrait.avatar-female_old {
  background: url("/static/avatars/female_old.png") center / cover no-repeat,
    radial-gradient(ellipse 40% 46% at 50% 48%, #00cc00 0%, #00cc00 98%, #0a0a0a 100%);
}
.avatar-portrait.avatar {
  box-shadow: 0 0 0 2px rgba(180, 140, 60, 0.4);
}

.character-stats {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
  padding: 12px;
  background: #1b1b1b;
  border-radius: 12px;
  width: 100%;
}
.character-stats div { font-size: 0.95rem; }
.character-stats strong { color: #ffcc66; font-weight: 600; }

.treasure-map-section {
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #141414;
}
.treasure-map-heading {
  margin: 0 0 6px 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
#sidebar-left .map-link {
  margin: 0;
  font-size: 0.85rem;
}
#sidebar-left .map-link a {
  color: #00cc00;
  text-decoration: none;
}
#sidebar-left .map-link a:hover {
  text-decoration: underline;
}

/* ZX81-style dice: blocky, green on black */
.player-dice-area,
.enemy-dice-area {
  padding: 10px;
  background: #0a0a0a;
  border: 1px solid #1a3d1a;
  border-radius: 2px;
  width: 100%;
}
.player-dice-area .dice-label,
.enemy-dice-area .dice-label {
  display: block;
  font-size: 0.75rem;
  color: #00cc00;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.dice-pair {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.dice-pair:last-child { margin-bottom: 0; }
.player-dice-stats .dice-pair:last-child { margin-bottom: 0; }
.player-dice-stats .dice-label { margin-top: 8px; }
.player-dice-stats .dice-label:first-child { margin-top: 0; }
.health-plus-six {
  color: #00cc00;
  font-size: 0.7rem;
  align-self: center;
  margin-left: 2px;
}
.die.zx81-die {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  width: 28px;
  height: 28px;
  background: #0a0a0a;
  border: 1px solid #1a3d1a;
  border-radius: 0;
  padding: 2px;
  gap: 1px;
}
.die.zx81-die .pip {
  width: 100%;
  height: 100%;
  min-width: 4px;
  min-height: 4px;
  background: transparent;
  border-radius: 0;
}
.die.zx81-die[data-face="1"] .pip:nth-child(5) { background: #00cc00; }
.die.zx81-die[data-face="2"] .pip:nth-child(1),
.die.zx81-die[data-face="2"] .pip:nth-child(9) { background: #00cc00; }
.die.zx81-die[data-face="3"] .pip:nth-child(1),
.die.zx81-die[data-face="3"] .pip:nth-child(5),
.die.zx81-die[data-face="3"] .pip:nth-child(9) { background: #00cc00; }
.die.zx81-die[data-face="4"] .pip:nth-child(1),
.die.zx81-die[data-face="4"] .pip:nth-child(3),
.die.zx81-die[data-face="4"] .pip:nth-child(7),
.die.zx81-die[data-face="4"] .pip:nth-child(9) { background: #00cc00; }
.die.zx81-die[data-face="5"] .pip:nth-child(1),
.die.zx81-die[data-face="5"] .pip:nth-child(3),
.die.zx81-die[data-face="5"] .pip:nth-child(5),
.die.zx81-die[data-face="5"] .pip:nth-child(7),
.die.zx81-die[data-face="5"] .pip:nth-child(9) { background: #00cc00; }
.die.zx81-die[data-face="6"] .pip:nth-child(1),
.die.zx81-die[data-face="6"] .pip:nth-child(3),
.die.zx81-die[data-face="6"] .pip:nth-child(4),
.die.zx81-die[data-face="6"] .pip:nth-child(6),
.die.zx81-die[data-face="6"] .pip:nth-child(7),
.die.zx81-die[data-face="6"] .pip:nth-child(9) { background: #00cc00; }

.main-content {
  grid-column: 2;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);
}
#game-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.enemy-sidebar {
  display: none;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
  width: 200px;
  grid-column: 3;
}
.enemy-sidebar.show {
  display: flex !important;
}
.enemy-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
.enemy-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #1b1b1b;
  border-radius: 12px;
  border: 1px solid #333;
}
.enemy-image { display: flex; justify-content: center; width: 100%; }
.enemy-placeholder {
  width: 150px;
  height: 150px;
  background: #1b1b1b;
  border: 2px solid #333;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 0.9rem;
}
.enemy-stats {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
  padding: 12px;
  background: #1b1b1b;
  border-radius: 12px;
  width: 100%;
}
.enemy-stats div { font-size: 0.95rem; }
.enemy-stats strong { color: #ffcc66; font-weight: 600; }
.story-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
}
.story-area-game {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.story-text-strip {
  flex-shrink: 0;
  min-height: 240px;
  max-height: 380px;
  overflow-y: auto;
  padding: 16px 20px;
  background: #0a0a0a;
  border-top: 1px solid #1a3d1a;
  text-align: center;
}
.story-text-strip .text {
  margin: 8px 0;
}
.story-text-strip .msg,
.story-text-strip .roll,
.story-text-strip .end {
  margin: 4px 0;
}
.story-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
.story-content.character-create-content {
  gap: 24px;
}
.story-content.character-create-content .character-create,
.story-content.character-create-content .avatar-select,
.story-content.character-create-content .adventure-select {
  margin: 0;
}
.adventure-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.adventure-select-label {
  font-size: 0.9rem;
  color: #aaa;
}
.adventure-select-input {
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #1b1b1b;
  color: #eee;
  font-size: 1rem;
  min-width: 200px;
}
.battle-status {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #141414;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  text-align: left;
  width: 100%;
  max-width: 600px;
}
.story-media {
  min-height: 200px;
  margin-top: 20px;
  /* Placeholder for future images/animations */
}

/* Pixel-art sunset scenery: fills story area; fallbacks when img fails to load */
.scenery {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 160px;
  border: 2px solid #452c5c;
  border-radius: 0;
  background-color: #181428;
  isolation: isolate;
}
.scenery .scenery-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* contain so full scene (sky, trees, ground) is visible; cover was cropping to stripes */
  object-fit: contain;
  object-position: center;
  display: block;
  z-index: 1;
}
.battle-overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 0;
}
.battle-scene-status {
  align-self: flex-start;
  display: inline-block;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #5e2f2f;
  background: rgba(16, 8, 8, 0.84);
  color: #ffb2b2;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 120, 120, 0.35);
}
.battle-result-overlay {
  position: relative;
  display: block;
  margin: 0 auto;
  width: min(94%, 620px);
  max-width: 620px;
  padding: 10px 14px;
  border: 2px solid #777;
  border-radius: 6px;
  background: rgba(10, 10, 12, 0.86);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: battleResultEnter 320ms ease-out both;
}
.battle-result-battle {
  background:
    linear-gradient(180deg, rgba(44, 16, 16, 0.9) 0%, rgba(16, 10, 10, 0.9) 100%),
    rgba(10, 10, 12, 0.86);
}
.battle-result-check {
  background:
    linear-gradient(180deg, rgba(14, 20, 34, 0.9) 0%, rgba(10, 12, 18, 0.9) 100%),
    rgba(10, 10, 12, 0.86);
  border-style: dashed;
}
.battle-result-headline {
  display: block;
  margin: 0;
  font-size: clamp(1.15rem, 3.2vw, 2.1rem);
  font-weight: 900;
  line-height: 1.15;
}
.battle-result-detail {
  display: block;
  margin: 6px 0 0 0;
  font-size: clamp(0.72rem, 1.25vw, 0.92rem);
  opacity: 0.92;
  letter-spacing: 0.04em;
  text-transform: none;
}
.battle-result-victory {
  border-color: #75a348;
  color: #e8ffd5;
  text-shadow: 0 0 10px rgba(156, 221, 93, 0.45);
  box-shadow: 0 0 0 1px rgba(160, 220, 99, 0.35), 0 8px 20px rgba(0, 0, 0, 0.55);
  animation: battleResultEnter 320ms ease-out both, victoryPulse 850ms ease-out 1;
}
.battle-result-defeat {
  border-color: #a34545;
  color: #ffd7d7;
  text-shadow: 0 0 10px rgba(255, 120, 120, 0.45);
  box-shadow: 0 0 0 1px rgba(206, 92, 92, 0.35), 0 8px 20px rgba(0, 0, 0, 0.55);
  animation: battleResultEnter 320ms ease-out both, defeatShake 360ms ease-out 1;
}
.battle-result-attack,
.battle-result-success {
  border-color: #658c47;
  color: #d7f8c0;
  text-shadow: 0 0 10px rgba(156, 221, 93, 0.42);
}
.battle-result-danger,
.battle-result-failure {
  border-color: #8f4444;
  color: #ffd0d0;
  text-shadow: 0 0 10px rgba(220, 93, 93, 0.4);
}
.battle-result-tie {
  border-color: #7f6f4a;
  color: #f8eecf;
  text-shadow: 0 0 8px rgba(245, 202, 109, 0.34);
}
.battle-result-neutral {
  border-color: #606070;
  color: #d6d9e6;
}
.scenery-battle-active::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.52) 88%),
    linear-gradient(180deg, rgba(66, 18, 18, 0.18) 0%, rgba(20, 6, 6, 0.08) 55%, rgba(66, 18, 18, 0.2) 100%);
  animation: battleVignettePulse 2.4s ease-in-out infinite;
}
.scenery-battle-recent {
  box-shadow: inset 0 0 0 1px rgba(255, 118, 118, 0.25), inset 0 0 36px rgba(255, 100, 100, 0.14);
}
.battle-impact-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 200, 120, 0.18) 0%, rgba(255, 200, 120, 0) 54%),
    radial-gradient(circle at 50% 62%, rgba(255, 110, 110, 0.18) 0%, rgba(255, 110, 110, 0) 58%);
  animation: battleImpactFade 520ms ease-out 1 forwards;
}
.scenery-default {
  background: linear-gradient(180deg, #452c5c 0%, #2d5a3d 50%, #181428 100%);
  box-shadow: inset 0 0 60px rgba(255, 153, 51, 0.08);
}
/* Forest: sky, dark mid, ground (matches generated scene; fallback when img fails) */
.scenery-forest {
  background: linear-gradient(180deg, #452c5c 0%, #452c5c 25%, #181428 25%, #181428 85%, #2d5a3d 85%, #2d5a3d 100%);
  box-shadow: inset 0 0 60px rgba(45, 90, 61, 0.2);
}
.scenery-river {
  background: linear-gradient(180deg, #181428 0%, #2d3a5c 35%, #2d3a5c 50%, #2d3a5c 65%, #181428 100%);
  box-shadow: inset 0 0 50px rgba(45, 58, 92, 0.3);
}
.scenery-hills {
  background: linear-gradient(180deg, #2d5a3d 0%, #1a4520 25%, #181428 50%, #1a4520 75%, #181428 100%);
  box-shadow: inset 0 0 50px rgba(45, 90, 61, 0.2);
}
.scenery-town {
  background: linear-gradient(180deg, #452c5c 0%, #3d2a48 30%, #2d3a4c 60%, #181428 100%);
  box-shadow: inset 0 0 60px rgba(196, 108, 50, 0.12);
}
.scenery-village {
  background: linear-gradient(180deg, #2d3a4c 0%, #1a2820 70%);
  box-shadow: inset 0 0 40px rgba(196, 108, 50, 0.1);
}
.scenery-road {
  background:
    linear-gradient(180deg, #181428 0%, #181428 32%, #555566 38%, #666677 50%, #555566 62%, #181428 68%, #181428 100%),
    linear-gradient(180deg, #1a1c28 0%, #252830 100%);
  box-shadow: inset 0 0 30px rgba(85, 85, 102, 0.2);
}
/* Shore: sunset sky, water, sand (harbor fallback) */
.scenery-shore {
  background: linear-gradient(180deg, #452c5c 0%, #2d3a5c 25%, #2d3a5c 45%, #8b7355 70%, #6b5344 100%);
  box-shadow: inset 0 0 60px rgba(255, 153, 51, 0.1);
}
.scenery-bridge {
  background: linear-gradient(180deg, #181428 0%, #555566 45%, #555566 55%, #181428 100%);
  box-shadow: inset 0 0 40px rgba(85, 85, 102, 0.2);
}
.scenery-clearing {
  background: radial-gradient(ellipse 120% 90% at 50% 85%, #6b8c5a 0%, #2d5a3d 35%, #181428 70%);
  box-shadow: inset 0 0 80px rgba(107, 140, 90, 0.25);
}
.scenery-house_inside {
  background: linear-gradient(180deg, #181428 0%, #555566 25%, #252830 100%);
  box-shadow: inset 0 0 80px rgba(196, 108, 50, 0.15);
}
.scenery-castle_inside {
  background: linear-gradient(180deg, #181428 0%, #454555 30%, #181428 100%);
  box-shadow: inset 0 0 60px rgba(196, 108, 50, 0.1);
}
.scenery-cave {
  background: linear-gradient(180deg, #0c0814 0%, #181428 50%, #0c0814 100%);
  box-shadow: inset 0 0 80px rgba(45, 58, 92, 0.15);
}
.scenery-dungeon {
  background: linear-gradient(180deg, #080610 0%, #181428 50%, #080610 100%);
  box-shadow: inset 0 0 60px rgba(45, 58, 92, 0.1);
}

/* Entry animation: door opening (runs once on node entry) */
@keyframes doorOpen {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}
.entry-animation-door_open {
  animation: doorOpen 0.5s ease-out 1 forwards;
}

@keyframes battleResultEnter {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(0.94);
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}
@keyframes victoryPulse {
  0% { box-shadow: 0 0 0 0 rgba(156, 221, 93, 0.42), 0 8px 20px rgba(0, 0, 0, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(156, 221, 93, 0), 0 8px 20px rgba(0, 0, 0, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(156, 221, 93, 0), 0 8px 20px rgba(0, 0, 0, 0.55); }
}
@keyframes defeatShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}
@keyframes battleVignettePulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 0.88; }
}
@keyframes battleImpactFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.choices-area {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid #333;
  background: #0a0a0a;
}
.text {
  font-size: 1.1rem;
  line-height: 1.6;
  margin: 16px 0;
  max-width: 600px;
}
.choices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  max-width: 800px;
}
.choice-prompt {
  width: 100%;
}
.prompt-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.prompt-question {
  width: 100%;
  text-align: center;
  font-size: 0.95rem;
  color: #ddd;
}
.prompt-input {
  padding: 10px 12px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #121212;
  color: #eee;
  font-family: 'Courier New', monospace;
  min-width: 220px;
}
.btn {
  padding: 12px 20px;
  border-radius: 8px;
  border: 2px solid #444;
  background: #1a1a1a;
  color: #eee;
  cursor: pointer;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  min-width: 150px;
  transition: all 0.2s;
}
.btn:hover {
  background: #2a2a2a;
  border-color: #666;
  transform: translateY(-1px);
}
.btn-battle-attack {
  border-color: #8f6a2d;
  background: linear-gradient(180deg, #2d2213 0%, #1c160d 100%);
  color: #f8dfb5;
  box-shadow: 0 0 0 1px rgba(143, 106, 45, 0.25) inset;
}
.btn-battle-attack:hover {
  border-color: #b3873f;
  background: linear-gradient(180deg, #3b2d17 0%, #241b10 100%);
}
.btn-battle-luck {
  border-color: #2d7f55;
  background: linear-gradient(180deg, #12261b 0%, #0f1d15 100%);
  color: #c8f2dd;
  box-shadow: 0 0 0 1px rgba(45, 127, 85, 0.24) inset;
}
.btn-battle-luck:hover {
  border-color: #3fa772;
  background: linear-gradient(180deg, #163123 0%, #11251b 100%);
}
.btn-battle-run {
  border-color: #7d3131;
  background: linear-gradient(180deg, #291414 0%, #1f1010 100%);
  color: #ffd1d1;
  box-shadow: 0 0 0 1px rgba(125, 49, 49, 0.24) inset;
}
.btn-battle-run:hover {
  border-color: #a64545;
  background: linear-gradient(180deg, #351a1a 0%, #261212 100%);
}
.btn-battle-attack,
.btn-battle-luck,
.btn-battle-run {
  animation: battleChoiceGlow 2.4s ease-in-out infinite;
}
@keyframes battleChoiceGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset; }
  50% { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset; }
}
.choices .btn {
  width: auto;
  flex: 0 1 auto;
}
.btn.primary { background: #2a4a2a; border-color: #3a6a3a; }
.btn.primary:hover { background: #3a5a3a; }
.msg { color: #ffcc66; }
.roll {
  color: #9ad;
  font-size: 0.84rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.end { opacity: 0.8; margin-top: 18px; }
.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: center;
  align-items: center;
}
.actions .btn {
  width: auto;
  flex: 0 1 auto;
  min-width: 150px;
}
form.begin-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
form.begin-form .story-area {
  flex: 1;
}
form.begin-form .choices-area {
  flex-shrink: 0;
}
.character-create {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.character-name-label {
  font-size: 0.9rem;
  color: #aaa;
}
.character-name-input {
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #1b1b1b;
  color: #eee;
  font-size: 1rem;
  min-width: 180px;
}
.avatar-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.avatar-select-label {
  font-size: 0.9rem;
  color: #aaa;
}
.avatar-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.avatar-option {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 4px;
}
.avatar-option:hover {
  border-color: #333;
}
.avatar-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.avatar-option input:checked + .avatar-preview {
  outline: 2px solid #00cc00;
  outline-offset: 2px;
}
.avatar-preview {
  width: 60px;
  height: 60px;
}

/* Respect user motion preferences for battle effects. */
@media (prefers-reduced-motion: reduce) {
  .entry-animation-door_open,
  .battle-result-overlay,
  .battle-result-victory,
  .battle-result-defeat,
  .scenery-battle-active::after,
  .battle-impact-layer,
  .btn-battle-attack,
  .btn-battle-luck,
  .btn-battle-run {
    animation: none !important;
  }

  .btn,
  .battle-result-overlay {
    transition: none !important;
  }

  .btn:hover {
    transform: none;
  }

  .battle-impact-layer {
    display: none;
  }
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr auto;
  }
  .sidebar {
    width: 100%;
    grid-column: 1;
    position: relative;
    top: 0;
  }
  .enemy-sidebar {
    width: 100%;
    grid-column: 1;
    position: relative;
    top: 0;
    margin-top: 16px;
  }
  .main-content {
    grid-column: 1;
    min-height: calc(100vh - 200px);
  }
  .story-area {
    padding: 16px;
  }
  .battle-overlay-layer {
    padding: 8px 8px 0;
    gap: 6px;
  }
  .battle-result-overlay {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
  }
  .battle-result-headline {
    font-size: clamp(1rem, 5.2vw, 1.45rem);
  }
  .battle-result-detail {
    font-size: 0.72rem;
  }
  .battle-scene-status {
    font-size: 0.64rem;
    padding: 5px 7px;
  }
  .story-content {
    padding: 0;
  }
  .choices-area {
    padding: 16px;
  }
  .choices {
    flex-direction: column;
    width: 100%;
  }
  .choices .btn {
    width: 100%;
    max-width: 400px;
  }
  .character-image { justify-content: flex-start; }
  .character-placeholder { width: 120px; height: 120px; }
  .character-stats { flex-direction: row; flex-wrap: wrap; }
}
