/* ============ Castle cellar ============
   Each section is one room of the cellar. Its picture is cut into three bands:
   the ceiling (top), one strip of plain brick wall that repeats as often as the
   content needs (middle), and the floor with the room's props (bottom).
   castle.js reads data-room on the section and sets the sizes, so a room is
   always exactly as tall as its content: no empty space under the blocks. */

body { background: #140000; }

#main section.floor { position: relative; isolation: isolate; overflow: hidden; image-rendering: pixelated; }
#main section.floor:not(.hero) {
  background-color: #1c1b1d;
  background-image: var(--bg-top), var(--bg-bot), var(--bg-mid);
  background-repeat: no-repeat, no-repeat, repeat-y;
  background-size: 100% auto, 100% auto, 100% var(--tile, 40px);
  background-position: center top, center bottom, center var(--top, 60px);
  padding: var(--pt, 120px) 0 var(--pb, 200px);
  display: flex; flex-direction: column; justify-content: center; gap: 24px;
}
.floor-1 { --bg-top: url("img/castle/room1-top.webp"); --bg-mid: url("img/castle/room1-mid.webp"); --bg-bot: url("img/castle/room1-bot.webp"); }
.floor-2 { --bg-top: url("img/castle/room2-top.webp"); --bg-mid: url("img/castle/room2-mid.webp"); --bg-bot: url("img/castle/room2-bot.webp"); }
.floor-3 { --bg-top: url("img/castle/room3-top.webp"); --bg-mid: url("img/castle/room3-mid.webp"); --bg-bot: url("img/castle/room3-bot.webp"); }
.floor-4 { --bg-top: url("img/castle/room4-top.webp"); --bg-mid: url("img/castle/room4-mid.webp"); --bg-bot: url("img/castle/room4-bot.webp"); }
.floor-5 { --bg-top: url("img/castle/room5-top.webp"); --bg-mid: url("img/castle/room5-mid.webp"); --bg-bot: url("img/castle/room5-bot.webp"); }
.floor-6 { --bg-top: url("img/castle/room6-top.webp"); --bg-mid: url("img/castle/room6-mid.webp"); --bg-bot: url("img/castle/room6-bot.webp"); }

.floor > .wrap { position: relative; z-index: 1; margin-left: auto; margin-right: auto; }
@media (min-width: 900px) { #main section.floor:not(.hero) > .wrap { width: min(1060px, 80vw); } }

/* soft dark glow behind the content so text stays readable on the wall */
.floor::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 50% 46% at 50% 50%, rgba(10, 6, 4, 0.55), rgba(10, 6, 4, 0.2) 65%, rgba(10, 6, 4, 0) 100%);
}
.floor h2, .floor .lead, .floor p { text-shadow: 0 2px 0 #000, 0 0 14px rgba(0, 0, 0, 0.85); }
/* parchment cards (the launch-day form) are light: no dark shadow on their text */
.floor .panel h2, .floor .panel p, .floor .panel label { text-shadow: none; }

/* the old flat textures are replaced by the rooms */
.floor.textured, .floor.band-night, .floor.band-night.textured { background-color: #1c1b1d; }

/* floor sign: small iron plaque hanging under the ceiling */
.floor-sign {
  position: absolute; z-index: 2; top: calc(var(--top, 60px) + 6px); left: 50%; transform: translateX(-50%);
  margin: 0; padding: 6px 16px 7px; white-space: nowrap;
  font-family: var(--pixel); font-size: clamp(14px, 1.3vw, 19px); color: var(--parchment);
  background: #2a1d14; border: 3px solid #0d0806; box-shadow: inset 0 0 0 2px #6b4b2a, 0 6px 0 rgba(0, 0, 0, 0.45);
  text-shadow: 0 2px 0 #000;
}
.floor-sign span { color: var(--gold); margin-right: 6px; }

/* torches sit on the floor band, bats fly across the whole room */
.room-fx.floor-fx { top: auto; bottom: 0; aspect-ratio: auto; height: var(--bot, 30%); }
.bat-fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

/* the pet parade walks on the armory floor */
#main .floor-3 .parade {
  position: absolute; left: 0; right: 0; bottom: calc(var(--fl, 10px) - 26px); z-index: 1; height: 118px;
  background: none; border: 0;
}

/* footer = bedrock under the last floor */
.site-footer { background: #0a0504 linear-gradient(#140000, #0a0504 60%); border-top: 0; }

/* ---------- living rooms: torch flames and bats ---------- */
.room-fx { position: absolute; left: 0; top: 0; width: 100%; aspect-ratio: 2336 / 1744; z-index: 0; pointer-events: none; overflow: hidden; }

.torch {
  position: absolute; width: var(--w, 1.8%); aspect-ratio: 14 / 22; transform: translate(-50%, -100%);
  background: url("img/castle/torch-flame.png") 0 0 / 800% 100% no-repeat; image-rendering: pixelated;
  animation: flame 0.8s steps(8) infinite; animation-delay: var(--d, 0s);
}
.torch::after { /* warm light on the wall */
  content: ""; position: absolute; left: 50%; top: 45%; width: 900%; aspect-ratio: 1; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 150, 50, 0.28), rgba(255, 120, 40, 0.10) 40%, rgba(255, 110, 40, 0) 70%);
  mix-blend-mode: screen; animation: glow 1.7s ease-in-out infinite alternate; animation-delay: var(--d, 0s);
}
.torch.sm::after { width: 600%; opacity: 0.7; }
.torch.big::after { width: 520%; }
.torch.nog::after { display: none; }
.torch.glow { background: none; animation: none; aspect-ratio: 1; transform: translate(-50%, -80%); }
.torch.glow::after { width: 380%; }
@keyframes flame { to { background-position: 114.2857% 0; } }
@keyframes glow { 0% { opacity: 0.75; transform: translate(-50%, -50%) scale(0.95); } 50% { opacity: 1; } 100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1.06); } }

.bat { position: absolute; left: -8%; width: calc(100px * var(--s, 0.5)); aspect-ratio: 110 / 103;
  animation: bat-ltr var(--dur, 20s) linear infinite; animation-delay: var(--dl, 0s); }
.bat.rtl { animation-name: bat-rtl; }
/* the bat beats its wings in 4 frames: up, open, down, open */
.bat i { position: absolute; inset: 0; background: url("img/castle/bat-flap.png") 0 0 / 400% 100% no-repeat; image-rendering: pixelated;
  animation: bat-flap 0.24s steps(4) infinite, bat-bob 2.4s ease-in-out infinite alternate; }

@keyframes bat-flap { to { background-position: 133.3333% 0; } }
@keyframes bat-bob { from { margin-top: -1.2%; } to { margin-top: 1.6%; } }
@keyframes bat-ltr { 0% { left: -8%; translate: 0 0; } 30% { translate: 0 40%; } 60% { translate: 0 -30%; } 100% { left: 108%; translate: 0 20%; } }
@keyframes bat-rtl { 0% { left: 108%; translate: 0 0; } 35% { translate: 0 -40%; } 70% { translate: 0 35%; } 100% { left: -8%; translate: 0 0; } }

@media (prefers-reduced-motion: reduce) {
  .torch, .torch::after, .bat, .bat i { animation: none; }
  .bat { display: none; }
}
.floor.hero .floor-sign { top: calc(clamp(16px, 3.2vw, 46px) + 58px); }

/* ---------- ground floor: one picture, the castle gate at night (2688 x 1520) ----------
   The picture always stands on the bottom of the section (the floor is the last row of slabs).
   On desktop it covers the whole screen-high section; extra height is cut from the sky.
   Words go on the plain wall on the left, the game logo hangs between the towers above the gate. */
#main section.floor.floor-0 { background-image: none; }
.room-fx.gate-fx { aspect-ratio: 2688 / 1520; background: url("img/castle/gate.webp") center / 100% 100% no-repeat; }
.gate-logo { display: none; }

@media (max-width: 899px) {
  #main section.floor.floor-0 { background-image: none, linear-gradient(rgba(20, 0, 0, 0.9), rgba(20, 0, 0, 0.9)), url("img/wall.png"); }
  #main section.floor.hero { padding-top: calc(100vw * 1520 / 2688 + 24px); }
  .floor-0 .floor-sign { display: none; }
  .gate-fx .bat { width: 34px; }
}

@media (min-width: 900px) {
  #main section.floor.hero {
    --h: max(480px, calc(100svh - 68px));
    --fh: max(var(--h), calc(100vw * 1520 / 2688));
    --fw: calc(var(--fh) * 2688 / 1520);
    height: var(--h);
    padding: max(16px, calc(var(--h) - var(--fh) * 0.69 + 12px)) 0 calc(var(--fh) * 0.06);
    background-color: #0b1020;
    display: flex; align-items: center;
  }
  .floor.hero .gate-fx { top: auto; bottom: 0; left: 50%; width: var(--fw); transform: translateX(-50%); }
  .floor.hero .gate-logo {
    display: block; position: absolute; left: 77.6%; bottom: 42.5%; width: 17%; height: auto;
    transform: translateX(-50%); image-rendering: pixelated;
  }
  .floor.hero .hero-logo, .floor.hero .floor-sign { display: none; }

  /* words: one wide column on the plain wall */
  .floor.hero .hero-grid { position: static; display: block; width: min(47vw, 660px); max-width: none; margin: 0 0 0 max(24px, 5vw); }
  .floor.hero .hero-head { display: block; }
  .floor.hero h1, .floor.hero .hero-body { position: relative; z-index: 2; }
  .floor.hero h1 { font-size: clamp(36px, 3.6vw, 60px); text-align: left; margin: 0 0 10px; line-height: 1.05; }
  .floor.hero .hero-body { max-width: none; text-align: left; }
  .floor.hero .pitch { font-size: clamp(16px, 1.3vw, 20px); margin: 0 0 16px; max-width: none; }
  .floor.hero .soon { margin: 12px 0 10px; }
  .floor.hero .tags { justify-content: flex-start; margin: 0 0 8px; }
  .floor.hero::before { z-index: 1; background: radial-gradient(ellipse 40% 46% at 26% 60%, rgba(8, 8, 14, 0.6), rgba(8, 8, 14, 0.2) 70%, transparent); }
}
@media (min-width: 900px) and (max-width: 1300px) { .floor.hero .tags li { font-size: 15px; padding: 5px 10px; } }
@media (max-width: 899px) { .bat-fx .bat { width: 34px; } }
/* gallery: the four phones stand side by side on desktop, no sideways scrolling */
@media (min-width: 900px) { .floor-5 .shelf { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); overflow: visible; } }

/* Single player: the game's own bot picker, a parchment panel with three dark plank buttons */
#main .mode.mode-sp {
  border: 44px solid transparent; border-image: url("img/ui-panel-9-slice.png") 22 / 44px round;
  background: radial-gradient(ellipse at 50% 40%, #E4C795 0%, #DBB885 60%, #D2AC77 100%) padding-box;
  box-shadow: none; padding: 6px 10px 10px; image-rendering: pixelated; gap: 14px;
}
#main .mode-sp h3 { color: var(--leather); text-shadow: none; }
#main .mode-sp p { color: #2b1f17; text-shadow: none; }
#main .mode.mode-sp { grid-template-rows: auto auto 1fr; }
#main .mode-sp .rivals { grid-template-columns: 1fr; grid-auto-rows: 1fr; gap: 12px; margin: 4px 0 0; }
#main .mode-sp .rival {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "gear level" "gear name" "gear coins";
  align-content: center; align-items: center; justify-items: start; text-align: left;
  column-gap: 16px; row-gap: 4px; padding: 12px 18px 12px 12px;
  background: linear-gradient(#463a35, #3a302c); border: 3px solid #1b1412;
  box-shadow: inset 0 0 0 2px #6e5d55, inset 0 -5px 0 rgba(0, 0, 0, 0.3), 0 3px 0 rgba(0, 0, 0, 0.25);
}
#main .mode-sp .rival-normal { border-color: #2a1a0c; box-shadow: inset 0 0 0 2px #b08a52, inset 0 -5px 0 rgba(0, 0, 0, 0.3), 0 3px 0 rgba(0, 0, 0, 0.25); }
.mode-sp .rival-gear { grid-area: gear; display: flex; gap: 6px; }
.mode-sp .slot { display: grid; place-items: center; width: 68px; height: 71px; background: center / 100% 100% no-repeat; image-rendering: pixelated; }
.mode-sp .slot-common { background-image: url("img/frame-common.png"); }
.mode-sp .slot-rare { background-image: url("img/frame-rare.png"); }
.mode-sp .slot-legendary { background-image: url("img/frame-legendary.png"); }
.mode-sp .slot img { width: 60px; height: 60px; border: 0; }
.mode-sp .rival-text { display: contents; }
.mode-sp .rival-level { grid-area: level; font: 24px/1 var(--pixel); color: #F5E1B1; }
.mode-sp .rival-normal .rival-level { color: #F2C14E; }
.mode-sp .rival-name { grid-area: name; font: 17px/1.1 var(--pixel); color: #CDBBA4; }
.mode-sp .rival-coins { grid-area: coins; justify-self: start; display: flex; align-items: center; gap: 6px; margin-top: 4px; font: 19px/1 var(--pixel); color: #fff; white-space: nowrap; }
.mode-sp .rival-coins img { width: 22px; height: 22px; border: 0; }
@media (max-width: 520px) {
  #main .mode.mode-sp { border-width: 28px; border-image-width: 28px; padding: 4px 6px 8px; }
  #main .mode-sp .rival { column-gap: 12px; padding: 10px 10px 10px 8px; }
  .mode-sp .rival-gear { gap: 4px; }
  .mode-sp .slot { width: 46px; height: 48px; } .mode-sp .slot img { width: 40px; height: 40px; }
  .mode-sp .rival-level { font-size: 21px; } .mode-sp .rival-name { font-size: 15px; } .mode-sp .rival-coins { font-size: 16px; }
}

/* ---------- Armory: the shop, in the game's store style ----------
   A stone sign, then parchment item cards with iron rivets; the item sits in its rarity frame. */
#main .loot-title { display: flex; justify-content: center; margin: 44px 0 20px; }
#main .loot-title span {
  display: inline-block; padding: 10px 44px 12px; font-size: clamp(26px, 2.4vw, 34px); letter-spacing: 0.06em; text-transform: uppercase;
  color: #F2C14E; text-shadow: 0 3px 0 #2a1608;
  background: linear-gradient(#5b5d62, #45474c); border: 4px solid #1a1a1d;
  box-shadow: inset 0 0 0 3px #7c7f85, inset 0 -6px 0 rgba(0, 0, 0, 0.35), 0 6px 0 rgba(0, 0, 0, 0.45);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
}
#main .loot-wall { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 16px 14px; }
@media (min-width: 1000px) { #main .loot-wall { grid-template-columns: repeat(7, 1fr); } }
#main .loot {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 6px; padding: 14px 8px 12px;
  background:
    radial-gradient(circle at 7px 7px, #2b2b2e 3px, #77787c 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 7px) 7px, #2b2b2e 3px, #77787c 4px, transparent 5px),
    radial-gradient(circle at 7px calc(100% - 7px), #2b2b2e 3px, #77787c 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 7px) calc(100% - 7px), #2b2b2e 3px, #77787c 4px, transparent 5px),
    radial-gradient(ellipse at 50% 35%, #EBD3A3 0%, #DDBF8B 60%, #CFAE77 100%);
  border: 3px solid #241811; box-shadow: inset 0 0 0 2px #f3e2bd, inset 0 -4px 0 rgba(90, 60, 30, 0.25), 0 5px 0 rgba(0, 0, 0, 0.45);
}
#main .loot > .loot-slot {
  display: grid; place-items: center; width: 92px; height: 96px; margin: 0;
  background: url("img/frame-common.png") center / 100% 100% no-repeat; image-rendering: pixelated;
}
#main .loot-rare > .loot-slot { background-image: url("img/frame-rare.png"); }
#main .loot-epic > .loot-slot { background-image: url("img/frame-epic.png"); }
#main .loot-legendary > .loot-slot { background-image: url("img/frame-legendary.png"); }
#main .loot .loot-slot > * { display: block; width: 64px; height: 64px; margin: 0; }
#main .loot .loot-name { color: #3a2418; font-size: 16px; line-height: 1.1; text-shadow: none; min-height: 2.2em; display: grid; place-items: center; }
#main .loot .loot-rarity {
  font-size: 14px; line-height: 1; padding: 6px 10px 5px; border-radius: 3px; text-shadow: none;
  background: #3a302c; border: 2px solid #1b1412; box-shadow: inset 0 0 0 1px #6e5d55; color: #C9C9C9;
}
#main .loot-rare .loot-rarity { color: #8EC2FF; }
#main .loot-epic .loot-rarity { color: #D9A6FF; }
#main .loot-legendary .loot-rarity { color: #F2C14E; }

/* the shopkeeper behind his counter, on the armory floor (behind the walking pets) */
.room-fx .shopkeeper { position: absolute; left: 50%; bottom: 5.5%; width: 27%; height: auto; transform: translateX(-50%); }
@media (max-width: 640px) {
  #main .loot-wall { grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
  #main .loot { padding: 12px 4px 10px; }
  #main .loot > .loot-slot { width: 70px; height: 73px; }
  #main .loot .loot-slot > * { width: 50px; height: 50px; }
  #main .loot .loot-name { font-size: 13px; }
  #main .loot .loot-rarity { font-size: 11px; padding: 5px 6px 4px; }
}
