/*
  DS-style retro screens for /appear-test/ and /battle/.
  Everything inside .ds is measured in DS pixels (each screen is 256×192) and the whole
  console is zoomed to fit the window by engine.js.
  Pixel font: "Pokemon DPPt" (kazumi213), a recreation of the Diamond/Pearl/Platinum text font.
*/

@font-face {
  font-family: "Pokemon DPPt";
  src: url("../fonts/pokemon-dppt.woff2") format("woff2");
  font-display: block;
}

[hidden] { display: none !important; }

.game {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--cream);
  background: radial-gradient(circle at 50% -10%, #3a6296, #1c2f4d 70%) fixed;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 6px;
}
.game-title {
  margin: 0;
  font: normal clamp(1.1rem, 3.5vw, 1.6rem) / 1.1 "Pokemon Solid", sans-serif;
  letter-spacing: .05em;
  color: var(--yellow);
  text-shadow: 2px 0 var(--navy), -2px 0 var(--navy), 0 2px var(--navy), 0 -2px var(--navy), 2px 3px var(--red);
}

/* appear test: a plain window on the homepage sky, as it would sit in the hero */
.game--sky { background: linear-gradient(var(--sky-top), var(--sky-bottom)) fixed; }
.window {
  width: fit-content;
  margin: 8px auto 16px;
  overflow: hidden;
  border: 4px solid var(--navy);
  border-radius: 16px;
  box-shadow: 7px 9px 0 var(--red);
  cursor: pointer;
}
.ds.ds--window { margin: 0; padding: 0; border-radius: 0; background: none; box-shadow: none; }

/* ---------- the console ---------- */

.ds {
  width: fit-content;
  margin: 6px auto 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #2a2e38;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px #454b58, 0 5px 0 #11141a;
}
.ds.is-row { flex-direction: row; }

.screen {
  position: relative;
  flex: none;
  width: 256px;
  height: 192px;
  overflow: hidden;
  background: #000;
  font: 16px/16px "Pokemon DPPt", monospace;
  color: #404048;
  -webkit-font-smoothing: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.screen canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

.layer, .scene, .side { position: absolute; left: 0; top: 0; width: 256px; height: 192px; }
.bg { z-index: 0; }
.scene { z-index: 1; }
.fx { z-index: 2; pointer-events: none; }
.world { z-index: 5; }
.overlay { z-index: 6; pointer-events: none; }

.platform { position: absolute; }
.mon { position: absolute; transform-origin: 50% 100%; }
.mon.is-fainting { overflow: hidden; }
.mon__sprite { position: relative; width: 100%; height: 100%; }
.ds-shadow { position: absolute; }
.mon.is-bobbing .mon__sprite { animation: ds-bob .64s steps(1) infinite; }
@keyframes ds-bob { 50% { transform: translateY(1px); } }

/* ---------- HP boxes ---------- */

.hpbox {
  position: absolute;
  z-index: 3;
  color: #404048;
  text-shadow: 1px 0 #d8d8d0, 0 1px #d8d8d0, 1px 1px #d8d8d0;
  background: #f8f8f0;
  border: 2px solid #404850;
  box-shadow: inset 0 -2px 0 #d0d0c4;
}
.hpbox--enemy { left: -2px; top: 12px; width: 126px; height: 32px; border-radius: 0 8px 8px 0; }
.hpbox--player { right: -2px; top: 99px; width: 128px; height: 44px; border-radius: 8px 0 0 8px; }
.hpbox::after { content: ""; position: absolute; top: 9px; border: 5px solid transparent; }
.hpbox--enemy::after { right: -12px; border-left-color: #404850; }
.hpbox--player::after { left: -12px; border-right-color: #404850; }
.hpbox.is-bobbing { animation: ds-bob .64s steps(1) infinite; }
/* party screen: the enemy box becomes a title tab for the prompt */
.hpbox--title { height: 20px; }
.hpbox--title .hpbox__lv, .hpbox--title .hpbox__bar { display: none; }
.hpbox--title::after { top: 3px; }
.hpbox__name { position: absolute; left: 6px; top: 0; }
.hpbox--player .hpbox__name { left: 10px; }
.hpbox__lv { position: absolute; right: 8px; top: 0; }
.hpbox--player .hpbox__lv { right: 6px; }
.hpbox__bar { position: absolute; right: 8px; top: 18px; }
.hpbox--player .hpbox__bar { right: 6px; top: 17px; }
.hpbox__num { position: absolute; right: 6px; top: 24px; }

/* ---------- text box ---------- */

.textbox {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  padding: 6px 28px 0 12px;
  background: #f8f8f8;
  border: 3px solid #505860;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #c8d0d8, inset -12px 0 0 #b0bcc4, inset -13px 0 0 #e8eef2;
}
.textbox__text {
  margin: 0;
  white-space: pre-line;
  color: #505058;
  text-shadow: 1px 0 #d0d0c8, 0 1px #d0d0c8, 1px 1px #d0d0c8;
}
.textbox__more {
  position: absolute;
  right: 18px;
  bottom: 5px;
  width: 7px;
  height: 5px;
  background: #e05038;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  animation: ds-more .5s steps(1) infinite;
}
@keyframes ds-more { 50% { transform: translateY(2px); } }

/* ---------- touch screen (bottom) ---------- */

.screen--bottom {
  color: #ffffff;
  background-color: #2c3444;
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 6px);
}
.panel { position: absolute; inset: 0; }
.panel__logo {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 32px;
  line-height: 32px;
  color: rgba(255, 255, 255, .16);
}

.dsbtn {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  color: #ffffff;
  text-decoration: none;
  text-shadow: 1px 0 #282830, -1px 0 #282830, 0 1px #282830, 0 -1px #282830, 1px 1px #282830;
  background: linear-gradient(var(--hi) 0 50%, var(--lo) 50%);
  border: 2px solid #202028;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35), 0 2px 0 #14161c;
  cursor: pointer;
}
.dsbtn:hover { filter: brightness(1.08); }
.dsbtn:active { transform: translateY(1px); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35); }
.dsbtn:focus-visible { outline: 2px solid #f8d030; outline-offset: 1px; }
.dsbtn:disabled { filter: grayscale(1) brightness(.7); cursor: default; }

.dsbtn--fight { --hi: #f87868; --lo: #e04838; left: 16px; top: 16px; width: 224px; height: 104px; font-size: 32px; line-height: 32px; }
.dsbtn--run { --hi: #6898f8; --lo: #3868d8; left: 68px; top: 138px; width: 120px; height: 40px; }
.dsbtn--cancel,
.dsbtn--home { --hi: #b0b0c0; --lo: #7c7c8c; left: 68px; top: 142px; width: 120px; height: 36px; }
.dsbtn--again { --hi: #78d868; --lo: #48b038; left: 16px; top: 22px; width: 224px; height: 100px; font-size: 32px; line-height: 32px; }
.dsbtn--ok { --hi: #78d868; --lo: #48b038; right: 4px; top: 152px; width: 122px; height: 34px; }
.dsbtn--back { --hi: #b0b0c0; --lo: #7c7c8c; left: 4px; top: 152px; width: 122px; height: 34px; }

.movebtn { top: 16px; width: 120px; height: 104px; align-content: center; gap: 10px; }
.movebtn--0 { left: 6px; }
.movebtn--1 { right: 6px; }
.movebtn__type { opacity: .85; }
.type--grass { --hi: #88d868; --lo: #58a838; }
.type--fire { --hi: #f89858; --lo: #d86828; }
.type--water { --hi: #78a8f8; --lo: #4878d8; }
.type--electric { --hi: #f8d858; --lo: #d0a018; }
.type--normal { --hi: #c8c0a0; --lo: #a09878; }

/* party picker: 2 × 3 slots like the DS party screen */
.party {
  position: absolute;
  left: 4px;
  top: 4px;
  display: grid;
  grid-template-columns: repeat(2, 122px);
  gap: 4px;
}
.slot {
  position: relative;
  width: 122px;
  height: 45px;
  padding: 0;
  font: inherit;
  color: #404048;
  text-align: left;
  text-shadow: 1px 1px #c8d0d8;
  background: #e4ecf4;
  border: 2px solid #203048;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #ffffff;
  cursor: pointer;
}
.slot canvas { position: absolute; }
.slot__icon { left: 2px; top: 5px; width: 32px; height: 32px; }
.slot__name { position: absolute; left: 36px; top: 4px; }
.slot__bar { left: 36px; top: 26px; }
.slot__tag { position: absolute; left: 36px; top: 22px; color: #c83820; text-shadow: 1px 1px #f0c8b8; }
.slot[aria-pressed="true"] {
  background: #fff4c8;
  border-color: #b85c10;
  box-shadow: inset 0 0 0 1px #ffffff, 0 0 0 1px #f8a838;
}
.slot:focus-visible { outline: 2px solid #f8d030; outline-offset: 0; }
.slot:disabled { opacity: .5; cursor: default; }

/* ---------- controls under the screen (appear test) ---------- */

.game-below {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 16px;
  padding: 0 16px 18px;
  font-weight: 700;
}
.game-below select {
  margin-left: 6px;
  padding: 5px 8px;
  font: inherit;
  color: var(--navy);
  background: var(--cream);
  border: 3px solid var(--navy);
  border-radius: 10px;
}
.seg { display: inline-flex; gap: 6px; }
.seg .btn[aria-pressed="false"] { background: var(--cream); }
