:root {
  color-scheme: light;
  --red: #d8202b;
  --red-dark: #8f121b;
  --red-deep: #3c070c;
  --yellow: #ffd449;
  --blue: #4fc3ff;
  --green: #47d36c;
  --ink: #141414;
  --muted: #66645f;
  --paper: #f7f0e4;
  --screen: #132322;
  --screen-glow: #d8fff1;
  --line: #250d10;
  --shadow: 0 34px 70px rgba(50, 8, 12, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(90deg, rgba(20, 20, 20, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(20, 20, 20, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 50% 12%, rgba(79, 195, 255, 0.2), transparent 28%),
    var(--paper);
  background-size: 28px 28px, 28px 28px, auto, auto;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

.dex-page {
  min-height: 100vh;
}

.dex-cover {
  display: grid;
  min-height: 100vh;
  align-content: start;
  gap: clamp(18px, 4vw, 34px);
  padding: clamp(16px, 3vw, 32px);
}

.dex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.dex-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.dex-mark strong,
.dex-mark small {
  display: block;
}

.dex-mark strong {
  font-size: 1.08rem;
  line-height: 1;
}

.dex-mark small,
.private-chip,
.screen-kicker,
.stat-card span,
.info-grid span,
.message-panel span,
.mini-terminal span {
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dex-mark small {
  color: var(--muted);
}

.dex-lens {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 4px solid #fff;
  border-radius: 999px;
  background:
    radial-gradient(circle at 28% 24%, #fff 0 11%, transparent 12%),
    radial-gradient(circle at 54% 55%, #83e4ff, #118ccd 60%, #064a73);
  box-shadow:
    0 0 0 3px var(--line),
    0 10px 18px rgba(6, 74, 115, 0.3);
}

.private-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  padding: 6px 12px;
}

.pokedex-device {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) 42px minmax(330px, 1.05fr);
  width: min(1180px, 100%);
  min-height: 690px;
  justify-self: center;
  filter: drop-shadow(var(--shadow));
}

.pokedex-left,
.pokedex-right,
.pokedex-hinge {
  border: 4px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.24), transparent 30%),
    var(--red);
}

.pokedex-left {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto;
  gap: 18px;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 28px 8px 8px 28px;
}

.pokedex-hinge {
  border-left: 0;
  border-right: 0;
  background:
    linear-gradient(90deg, var(--red-dark), #f15a60 18%, var(--red) 50%, var(--red-dark));
}

.pokedex-right {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 8px 28px 28px 8px;
}

.device-lights,
.control-row,
.type-row,
.dex-footer {
  display: flex;
  align-items: center;
}

.device-lights {
  gap: 13px;
}

.device-lights i {
  width: 18px;
  height: 18px;
  border: 3px solid var(--line);
  border-radius: 999px;
}

.device-lights .red {
  background: #ff4050;
}

.device-lights .yellow {
  background: var(--yellow);
}

.device-lights .green {
  background: var(--green);
}

.avatar-screen {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 330px;
  place-items: center;
  overflow: hidden;
  border: 14px solid #fff8ec;
  border-radius: 9px;
  background:
    linear-gradient(90deg, rgba(216, 255, 241, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(216, 255, 241, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 50% 48%, rgba(79, 195, 255, 0.16), transparent 34%),
    var(--screen);
  background-size: 16px 16px, 16px 16px, auto, auto;
  box-shadow:
    inset 0 0 0 4px var(--line),
    0 7px 0 var(--line);
  cursor: pointer;
}

.avatar-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 0 42%, rgba(255, 255, 255, 0.08) 43% 47%, transparent 48%);
  pointer-events: none;
}

.avatar-screen img {
  z-index: 1;
  display: block;
  width: min(78%, 360px);
  height: min(78%, 360px);
  object-fit: contain;
  filter: drop-shadow(0 18px 20px rgba(0, 0, 0, 0.4));
}

.avatar-screen:not(.has-image) img {
  display: none;
}

.avatar-initial {
  color: var(--screen-glow);
  font-size: clamp(5rem, 18vw, 9rem);
  font-weight: 950;
  line-height: 1;
}

.avatar-screen.has-image .avatar-initial {
  display: none;
}

.tap-label {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: rgba(216, 255, 241, 0.78);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.control-row {
  justify-content: space-between;
  gap: 14px;
}

.round-pad {
  width: 54px;
  height: 54px;
  border: 4px solid var(--line);
  border-radius: 999px;
  background: #171717;
}

.pill-button {
  width: 82px;
  height: 22px;
  border: 3px solid var(--line);
  border-radius: 999px;
}

.pill-button.red {
  background: #ff5360;
}

.pill-button.blue {
  background: var(--blue);
}

.mini-terminal {
  display: grid;
  gap: 9px;
  min-height: 168px;
  padding: 13px;
  border: 4px solid var(--line);
  border-radius: 8px;
  background: #a7db7a;
  color: #173312;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mini-terminal-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.mini-terminal strong {
  font-size: 1.08rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.mini-profile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.mini-profile-grid div {
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 2px solid #173312;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.22);
  padding: 6px;
}

.mini-profile-grid span {
  color: #173312;
  font-size: 0.58rem;
}

.mini-profile-grid strong {
  font-size: 0.78rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.mini-stat-grid .stat-card {
  gap: 5px;
  padding: 7px;
  border-width: 2px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

.mini-stat-grid .stat-card span {
  color: #173312;
  font-size: 0.62rem;
}

.mini-stat-grid .stat-card strong {
  font-size: 1rem;
}

.mini-stat-grid .stat-bar {
  height: 7px;
  border-width: 2px;
}

.profile-screen,
.message-panel {
  border: 4px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(216, 255, 241, 0.1) 50%, rgba(19, 35, 34, 0.1) 50%),
    var(--screen);
  background-size: 100% 8px;
  color: var(--screen-glow);
  box-shadow: inset 0 0 26px rgba(79, 195, 255, 0.13);
}

.profile-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, 31%);
  gap: clamp(12px, 2vw, 18px);
  aspect-ratio: 16 / 9;
  min-height: 0;
  align-items: center;
  padding: clamp(14px, 2.4vw, 22px);
}

.screen-kicker {
  margin: 0 0 8px;
  color: #8feaff;
}

.profile-screen h1 {
  margin: 0;
  font-size: clamp(2.3rem, 5.6vw, 4.2rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.trainer-profile-copy {
  min-width: 0;
}

.trainer-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
  margin-top: 12px;
}

.trainer-meta-grid div {
  display: block;
  min-width: 0;
  padding: 0;
}

.trainer-meta-grid span {
  display: block;
  color: #8feaff;
  font-size: 0.62rem;
  font-weight: 950;
  text-transform: uppercase;
}

.trainer-meta-grid strong {
  display: block;
  color: var(--screen-glow);
  font-size: clamp(0.8rem, 1.7vw, 0.98rem);
  line-height: 1.04;
  overflow-wrap: anywhere;
}

.trainer-photo {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  margin: 0;
  border: 3px solid rgba(216, 255, 241, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(216, 255, 241, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(216, 255, 241, 0.07) 1px, transparent 1px),
    rgba(216, 255, 241, 0.08);
  background-size: 12px 12px;
}

.trainer-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.trainer-photo:not(.has-image) img {
  display: none;
}

.trainer-photo span {
  color: var(--screen-glow);
  font-size: clamp(3rem, 9vw, 5rem);
  font-weight: 950;
}

.trainer-photo.has-image span {
  display: none;
}

.type-row {
  gap: 8px;
  flex-wrap: wrap;
  margin: 15px 0;
}

.type-row span {
  border: 2px solid rgba(216, 255, 241, 0.84);
  border-radius: 999px;
  color: #fff;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 950;
  text-transform: uppercase;
}

.message-panel p {
  margin: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #69c7ef;
  box-shadow: 0 4px 0 var(--line);
}

.stat-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
}

.stat-card strong {
  font-size: 1.48rem;
  line-height: 1;
}

.stat-bar {
  height: 9px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
}

.stat-bar i {
  display: block;
  width: var(--bar);
  height: 100%;
  background: var(--yellow);
}

.message-panel {
  min-height: 128px;
  padding: 15px;
}

.message-panel span {
  display: block;
  margin-bottom: 8px;
  color: #8feaff;
}

.message-panel p {
  color: rgba(216, 255, 241, 0.88);
}

.dex-footer {
  justify-content: space-between;
  gap: 12px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 20px;
  max-width: min(460px, calc(100vw - 28px));
  transform: translateX(-50%);
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  padding: 10px 14px;
  font-weight: 850;
}

@media (max-width: 980px) {
  .pokedex-device {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .pokedex-left {
    border-radius: 26px 26px 8px 8px;
  }

  .pokedex-hinge {
    min-height: 34px;
    border: 0;
    border-left: 4px solid var(--line);
    border-right: 4px solid var(--line);
  }

  .pokedex-right {
    border-radius: 8px 8px 26px 26px;
  }
}

@media (max-width: 680px) {
  .dex-cover {
    padding: 14px;
  }

  .dex-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .private-chip {
    align-self: stretch;
    justify-content: center;
  }

  .pokedex-left,
  .pokedex-right {
    padding: 18px;
  }

  .avatar-screen {
    min-height: 260px;
  }

  .stat-grid,
  .mini-profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dex-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .profile-screen {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 31%);
    padding: 12px;
  }

  .profile-screen h1 {
    font-size: 2rem;
  }

  .trainer-meta-grid {
    gap: 4px 10px;
  }

  .trainer-meta-grid span {
    font-size: 0.56rem;
  }

  .trainer-meta-grid strong {
    font-size: 0.74rem;
  }

  .stat-grid,
  .mini-profile-grid {
    grid-template-columns: 1fr;
  }
}
