/*
 * Pokémon-only P2 presentation layer.
 *
 * This file is intentionally last in index.html.  It consolidates the active
 * player-facing shell without deleting the older revision files, so reverting
 * the pass is a one-line stylesheet removal.  Semantic illustrations continue
 * to come from Pokémon, trainer and inventory raster assets; CSS draws only
 * neutral chrome, spacing and state feedback.
 */

html[data-ui-revision="pokemon-next"] {
  --pk2-navy: #12384f;
  --pk2-navy-deep: #082a3e;
  --pk2-blue: #158fbe;
  --pk2-sky: #55c9ea;
  --pk2-red: #df3f4c;
  --pk2-yellow: #f2c64d;
  --pk2-paper: #f8fdff;
  --pk2-paper-soft: #eaf7fb;
  --pk2-line: rgba(44, 125, 159, .23);
  --pk2-shadow: 0 22px 64px rgba(3, 34, 53, .26);
  --pk2-font: "Onest PokePark", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

html[data-ui-revision="pokemon-next"] :where(body, button, input, select, textarea) {
  font-family: var(--pk2-font) !important;
}

html[data-ui-revision="pokemon-next"] :where(button, [role="button"], a) {
  touch-action: manipulation;
}

html[data-ui-revision="pokemon-next"] :where(.home-screen, .game-screen, .lab-games, .dialogue-layer, .starter-dialog) {
  -webkit-tap-highlight-color: transparent;
}

/* Dynamic semantic raster mounts must never fall back to their source bitmap
   dimensions (several Pokédex images are 550 × 724). */
html[data-ui-revision="pokemon-next"] .pokemon-semantic-raster {
  display: block;
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

html[data-ui-revision="pokemon-next"] #chatPanel :where(.chat-notice-raster, .chat-action-icon) {
  width: 18px !important;
  height: 18px !important;
}

html[data-ui-revision="pokemon-next"] #chatPanel :where(.chat-log-wrap, .chat-log) {
  overflow-x: hidden !important;
}

/* ---------- Continue screen: compact trainer dossier ---------- */

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) {
  color: var(--pk2-navy);
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .home-vignette {
  background:
    linear-gradient(180deg, rgba(4, 28, 40, .08), rgba(4, 25, 38, .55)),
    radial-gradient(circle at 50% 36%, transparent 24%, rgba(4, 27, 41, .18) 78%);
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .home-topbar {
  isolation: isolate;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .brand-mark,
html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .account-chip {
  border: 1px solid rgba(255, 255, 255, .8);
  background: rgba(248, 253, 255, .92) !important;
  box-shadow: 0 12px 30px rgba(4, 31, 48, .2), inset 0 1px 0 #fff !important;
  backdrop-filter: blur(14px);
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-home {
  gap: 12px;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-hero,
html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-card {
  border: 1px solid rgba(127, 201, 226, .46) !important;
  background:
    linear-gradient(145deg, rgba(248, 253, 255, .96), rgba(231, 247, 252, .93)) !important;
  color: var(--pk2-navy) !important;
  box-shadow: var(--pk2-shadow), inset 0 1px 0 #fff !important;
  backdrop-filter: blur(16px);
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-hero {
  position: relative;
  overflow: hidden;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-hero::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -98px;
  top: -122px;
  border: 28px solid rgba(223, 63, 76, .07);
  border-radius: 50%;
  box-shadow: inset 0 0 0 17px rgba(18, 56, 79, .045);
  pointer-events: none;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-eyebrow,
html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-card > small {
  color: var(--pk2-blue) !important;
  font-weight: 900;
  letter-spacing: .105em;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-hero h1,
html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-card b {
  color: var(--pk2-navy-deep) !important;
  text-wrap: balance;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-hero p,
html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-card p,
html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-profile-strip span {
  color: #557488 !important;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-profile-strip article {
  border: 1px solid rgba(62, 140, 173, .18) !important;
  background: rgba(255, 255, 255, .52) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .82) !important;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-profile-strip small {
  color: #6c8a9c !important;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-continue,
html[data-ui-revision="pokemon-next"] :where(.lab-games__footer > button, .dialogue-actions > button:last-child) {
  border: 1px solid rgba(255, 255, 255, .38) !important;
  background: linear-gradient(180deg, #28aee0, #087eaf) !important;
  color: #fff !important;
  box-shadow: 0 12px 24px rgba(6, 107, 150, .27), inset 0 1px 0 rgba(255, 255, 255, .36) !important;
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-continue:hover {
  filter: brightness(1.045);
  transform: translateY(-1px);
}

html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-card.is-featured {
  border-top: 3px solid var(--pk2-yellow);
}

/* ---------- World HUD: legibility and non-overlapping notifications ---------- */

html[data-ui-revision="pokemon-next"] #app[data-screen="game"] .toast {
  z-index: var(--pk-z-toast);
  border: 1px solid rgba(126, 207, 234, .42);
  background: rgba(8, 42, 62, .94);
  box-shadow: 0 14px 34px rgba(2, 23, 38, .32), inset 0 1px 0 rgba(255, 255, 255, .14);
  color: #f5fcff;
  font-weight: 760;
  line-height: 1.3;
  text-align: center;
}

html[data-ui-revision="pokemon-next"] .game-screen .world-topbar,
html[data-ui-revision="pokemon-next"] .game-screen .world-minimap,
html[data-ui-revision="pokemon-next"] .game-screen .quest-widget,
html[data-ui-revision="pokemon-next"] .game-screen .mobile-dock,
html[data-ui-revision="pokemon-next"] .game-screen .desktop-dock {
  isolation: isolate;
}

html[data-ui-revision="pokemon-next"] .game-screen .player-chip,
html[data-ui-revision="pokemon-next"] .game-screen .world-wallet,
html[data-ui-revision="pokemon-next"] .game-screen .quest-widget {
  border-color: rgba(111, 193, 222, .45) !important;
  box-shadow: 0 13px 32px rgba(3, 30, 47, .24), inset 0 1px 0 rgba(255, 255, 255, .8) !important;
}

html[data-ui-revision="pokemon-next"] .game-screen .player-chip-avatar,
html[data-ui-revision="pokemon-next"] .game-screen .resource-art-v74,
html[data-ui-revision="pokemon-next"] .game-screen .pokemon-nav-art {
  image-rendering: auto;
}

/* ---------- Shared Pokémon window chrome ---------- */

html[data-ui-revision="pokemon-next"] :where(
  .side-panel.hud-window,
  .professor-transfer-card-shell,
  .controls-tutorial-card,
  .pvp-invite__card
) {
  border: 1px solid rgba(100, 184, 215, .44) !important;
  background: linear-gradient(150deg, rgba(249, 253, 255, .98), rgba(231, 246, 251, .97)) !important;
  box-shadow: var(--pk2-shadow), inset 0 1px 0 #fff !important;
  color: var(--pk2-navy) !important;
}

html[data-ui-revision="pokemon-next"] :where(
  .panel-close,
  .professor-transfer-card-shell > header button,
  .controls-tutorial-card > header button
) {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  border: 1px solid rgba(63, 137, 168, .16) !important;
  border-radius: 14px !important;
  background: rgba(220, 239, 247, .78) !important;
  color: var(--pk2-navy) !important;
}

html[data-ui-revision="pokemon-next"] .dialogue-layer .dialogue-card {
  border: 1px solid rgba(105, 193, 222, .52);
  background: linear-gradient(155deg, rgba(250, 254, 255, .98), rgba(228, 245, 251, .97));
  box-shadow: 0 30px 90px rgba(2, 26, 43, .38), inset 0 1px 0 #fff;
  color: var(--pk2-navy);
}

html[data-ui-revision="pokemon-next"] .dialogue-layer .dialogue-card::before {
  background: linear-gradient(90deg, var(--pk2-red), #f26b67 32%, var(--pk2-yellow) 32% 43%, var(--pk2-blue) 43%);
}

html[data-ui-revision="pokemon-next"] .dialogue-layer :where(#dialogueSpeaker, #dialogueText) {
  color: var(--pk2-navy-deep);
}

html[data-ui-revision="pokemon-next"] .dialogue-layer :where(#dialogueProgress, .dialogue-hint) {
  color: #668497;
}

html[data-ui-revision="pokemon-next"] .dialogue-actions > button:first-child {
  border: 1px solid var(--pk2-line) !important;
  background: rgba(255, 255, 255, .74) !important;
  color: var(--pk2-navy) !important;
}

/* ---------- Laboratory terminal: Pokémon research presentation ---------- */

html[data-ui-revision="pokemon-next"] .lab-games {
  --lab-ink: var(--pk2-navy);
  --lab-muted: #58798b;
  color: var(--lab-ink);
}

html[data-ui-revision="pokemon-next"] .lab-games__shade {
  background: rgba(4, 27, 41, .68);
  backdrop-filter: blur(9px) saturate(.88);
}

html[data-ui-revision="pokemon-next"] .lab-games__shell {
  border: 1px solid rgba(116, 202, 231, .58);
  border-radius: 26px;
  background: linear-gradient(150deg, #f9fdff, #e5f4f9 72%);
  box-shadow: 0 32px 110px rgba(2, 27, 44, .42), inset 0 1px 0 #fff;
  color: var(--lab-ink);
}

html[data-ui-revision="pokemon-next"] .lab-games__shell::before {
  content: "";
  position: absolute;
  z-index: 4;
  top: 0;
  right: 88px;
  left: 88px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, var(--lab-accent), transparent);
  opacity: .9;
  pointer-events: none;
}

html[data-ui-revision="pokemon-next"] .lab-games__header {
  min-height: 72px;
  border-bottom: 1px solid var(--pk2-line);
  background: rgba(248, 253, 255, .88);
}

html[data-ui-revision="pokemon-next"] .lab-games__emblem {
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--lab-accent) 44%, #b8dce8);
  background: color-mix(in srgb, var(--lab-accent) 10%, #f8fdff);
  box-shadow: inset 0 1px 0 #fff, 0 7px 16px rgba(6, 62, 85, .1);
}

html[data-ui-revision="pokemon-next"] .lab-games__header h2 {
  color: var(--pk2-navy-deep);
  font-family: var(--pk2-font) !important;
  font-weight: 880;
  letter-spacing: -.035em;
}

html[data-ui-revision="pokemon-next"] .lab-games__header small {
  color: color-mix(in srgb, var(--lab-accent) 72%, var(--pk2-navy));
}

html[data-ui-revision="pokemon-next"] .lab-games__header > button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: 1px solid rgba(61, 139, 171, .14);
  border-radius: 14px;
  background: #e3f1f6;
  color: var(--pk2-navy);
  font-size: 25px;
  line-height: 1;
}

html[data-ui-revision="pokemon-next"] .lab-games__body {
  background:
    radial-gradient(circle at 14% 10%, color-mix(in srgb, var(--lab-accent) 11%, transparent), transparent 32%),
    linear-gradient(150deg, #eff9fc, #e3f2f7);
}

html[data-ui-revision="pokemon-next"] .lab-games__brief,
html[data-ui-revision="pokemon-next"] .lab-games__board {
  border: 1px solid rgba(82, 159, 190, .19);
  background: rgba(250, 254, 255, .82);
  color: var(--lab-ink);
  box-shadow: inset 0 1px 0 #fff;
}

html[data-ui-revision="pokemon-next"] .lab-games__brief p,
html[data-ui-revision="pokemon-next"] .lab-result p {
  color: var(--lab-muted);
}

html[data-ui-revision="pokemon-next"] .lab-games__arena:not(.lab-flight) {
  border: 1px solid color-mix(in srgb, var(--lab-accent) 25%, #b2d7e4);
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--lab-accent) 16%, #f8fdff), #e5f3f8 74%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .72), 0 10px 24px rgba(5, 54, 76, .09);
}

html[data-ui-revision="pokemon-next"] .lab-result {
  position: relative;
  gap: 10px;
}

html[data-ui-revision="pokemon-next"] .lab-result::before {
  content: "ИССЛЕДОВАНИЕ ПРОФЕССОРА ОУКА";
  color: color-mix(in srgb, var(--lab-accent) 66%, var(--pk2-navy));
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
}

html[data-ui-revision="pokemon-next"] .lab-result > img,
html[data-ui-revision="pokemon-next"] .lab-result > .pokemon-canonical-art {
  width: min(120px, 28%);
  height: min(120px, 28%);
  filter: drop-shadow(0 12px 18px rgba(6, 50, 72, .2));
}

html[data-ui-revision="pokemon-next"] .lab-result b {
  color: var(--pk2-navy-deep);
}

html[data-ui-revision="pokemon-next"] .lab-result em {
  border: 1px solid color-mix(in srgb, var(--lab-accent) 28%, #c4e0e9);
  background: color-mix(in srgb, var(--lab-accent) 10%, #f8fdff);
  color: var(--pk2-navy);
}

html[data-ui-revision="pokemon-next"] .lab-games__board h3 {
  color: color-mix(in srgb, var(--lab-accent) 76%, var(--pk2-navy));
}

html[data-ui-revision="pokemon-next"] .lab-games__board li {
  border: 1px solid rgba(58, 138, 170, .13);
  background: rgba(236, 248, 252, .88);
  color: var(--pk2-navy);
}

html[data-ui-revision="pokemon-next"] .lab-games__board li.is-player {
  border-color: color-mix(in srgb, var(--lab-accent) 70%, #7fb5c8);
  outline: 0;
  background: color-mix(in srgb, var(--lab-accent) 12%, #f8fdff);
}

html[data-ui-revision="pokemon-next"] .lab-games__footer {
  border-top: 1px solid var(--pk2-line);
  background: rgba(248, 253, 255, .94);
  color: var(--pk2-navy);
}

html[data-ui-revision="pokemon-next"] .lab-games__footer small {
  color: #6a8798;
}

html[data-ui-revision="pokemon-next"] .lab-games__footer > button {
  min-height: 48px;
}

/* Flight keeps its authored scene art; only its surrounding research device is unified. */
html[data-ui-revision="pokemon-next"] .lab-games[data-game-mode="flight"] .lab-games__body {
  background: #eaf7fb;
}

html[data-ui-revision="pokemon-next"] .lab-games[data-game-mode="flight"] .lab-games__arena {
  border-color: rgba(63, 166, 204, .45);
}

/* ---------- Mobile composition ---------- */

@media (max-width: 760px) {
  html[data-ui-revision="pokemon-next"] #app[data-screen="game"] .toast {
    top: calc(max(8px, var(--pk-safe-top)) + 112px) !important;
    width: max-content;
    max-width: calc(100vw - 136px);
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 12px;
    transform: translate(-50%, -8px);
    font-size: 10px;
  }

  html[data-ui-revision="pokemon-next"] #app[data-screen="game"] .toast.is-open {
    transform: translate(-50%, 0);
  }

  html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-home {
    gap: 8px;
  }

  html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-hero,
  html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-card {
    border-radius: 19px;
  }

  html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-profile-strip {
    gap: 6px;
  }

  html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-profile-strip article {
    border-radius: 12px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) {
    padding:
      max(5px, var(--pk-safe-top))
      max(5px, var(--pk-safe-right))
      max(5px, var(--pk-safe-bottom))
      max(5px, var(--pk-safe-left));
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__shell {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__header {
    min-height: 62px;
    gap: 9px;
    padding: 8px 10px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__emblem {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__header h2 {
    max-width: calc(100vw - 126px);
    overflow: hidden;
    font-size: clamp(16px, 4.8vw, 21px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__header small {
    display: block;
    max-width: calc(100vw - 126px);
    overflow: hidden;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(210px, 1fr) minmax(108px, auto);
    gap: 7px;
    padding: 7px;
    overflow: hidden;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__brief {
    grid-column: auto;
    min-height: 0;
    padding: 7px 9px;
    font-size: 10px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__arena {
    min-height: 210px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__board {
    min-height: 0;
    max-height: 142px;
    padding: 8px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__footer {
    min-height: 62px;
    gap: 10px;
    padding: 7px 9px max(7px, var(--pk-safe-bottom));
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__footer span {
    min-width: 46px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__footer b {
    font-size: 17px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__footer > button {
    min-width: 0;
    min-height: 48px;
    padding-inline: 14px;
    border-radius: 14px;
    font-size: 11px;
  }

  html[data-ui-revision="pokemon-next"] .dialogue-layer .dialogue-card {
    max-height: calc(100dvh - max(12px, var(--pk-safe-top)) - max(12px, var(--pk-safe-bottom)));
  }
}

@media (max-width: 390px) {
  html[data-ui-revision="pokemon-next"] #app[data-screen="game"] .toast {
    top: calc(max(6px, var(--pk-safe-top)) + 102px) !important;
    max-width: calc(100vw - 112px);
    font-size: 9px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__brief {
    display: none;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__body {
    grid-template-rows: minmax(230px, 1fr) minmax(104px, auto);
  }
}

@media (max-width: 760px) and (max-height: 560px) and (orientation: landscape) {
  html[data-ui-revision="pokemon-next"] #app[data-screen="game"] .toast {
    top: calc(max(6px, var(--pk-safe-top)) + 58px) !important;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__shell {
    grid-template-rows: 54px minmax(0, 1fr) 58px;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__body {
    grid-template-columns: minmax(0, 1fr) 190px;
    grid-template-rows: minmax(0, 1fr);
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__brief {
    display: none;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__arena {
    min-height: 0;
  }

  html[data-ui-revision="pokemon-next"] .lab-games:not([data-game-mode="flight"]) .lab-games__board {
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-ui-revision="pokemon-next"] .home-screen:is([data-mode="dashboard"], [data-mode="returning"]) .adventure-continue {
    transition: none !important;
  }
}
