:root {
  --bg: #1d1d1b;
  --bg-2: #242421;
  --ink: #f4f3ee;
  --muted: #b8b5ad;
  --faint: #8f8c84;
  --line: rgba(244, 243, 238, 0.14);
  --line-strong: rgba(217, 120, 85, 0.52);
  --panel: rgba(21, 21, 19, 0.9);
  --panel-strong: rgba(16, 16, 15, 0.96);
  --surface: rgba(244, 243, 238, 0.06);
  --surface-strong: rgba(217, 120, 85, 0.14);
  --green: #7d9162;
  --blue: #6d9dca;
  --gold: #d97855;
  --red: #c83d35;
  --violet: #a6a29a;
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.44);
  --focus: 0 0 0 3px rgba(217, 120, 85, 0.26);
  --font-ui: "Pretendard", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", system-ui, sans-serif;
  --font-display: "Pretendard", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", system-ui, sans-serif;
}

@view-transition {
  navigation: auto;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 16% 0%, rgba(217, 120, 85, 0.12), transparent 30%),
    linear-gradient(135deg, #1d1d1b 0%, #242421 50%, #1a1a18 100%);
  background-size: auto;
  color: var(--ink);
  font-family: var(--font-ui);
  letter-spacing: 0;
  opacity: 1;
  transition: opacity 0.18s ease, filter 0.18s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 0%, rgba(217, 120, 85, 0.12), transparent 32%),
    radial-gradient(circle at 82% 6%, rgba(109, 157, 202, 0.1), transparent 30%),
    linear-gradient(0deg, rgba(125, 145, 98, 0.08), transparent 34%);
  mask-image: linear-gradient(180deg, black, transparent 80%);
}

body.is-entering {
  animation: page-enter 0.22s ease both;
}

body.is-leaving {
  opacity: 0;
  filter: blur(5px);
}

body.start-active {
  overflow: hidden;
}

body.start-active .launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
}

.start-screen {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  z-index: 50;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: clamp(14px, 3vh, 28px);
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: #d97855;
  overflow: hidden;
  transition: opacity 0.36s ease, visibility 0.36s ease;
}

.start-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(244, 243, 238, 0.3), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 34%, rgba(0, 0, 0, 0.06));
}

.start-mark {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  align-self: end;
  gap: clamp(10px, 2.2vh, 18px);
  width: min(78vw, 820px);
  max-height: calc(100dvh - 118px);
  min-height: 0;
}

.start-logo {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(54dvh, 560px);
  min-height: 0;
  object-fit: contain;
  image-rendering: auto;
  filter: saturate(0.92) brightness(0.98) drop-shadow(0 22px 42px rgba(0, 0, 0, 0.18));
}

.start-credits {
  margin: 0;
  border-top: 5px solid #050505;
  padding-top: clamp(10px, 2vh, 18px);
  color: #050505;
  font-family: var(--font-ui);
  font-size: clamp(0.82rem, 1.5vw, 1.08rem);
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.start-button {
  position: relative;
  z-index: 2;
  min-width: 164px;
  min-height: 48px;
  margin-bottom: clamp(8px, 4vh, 34px);
  border: 2px solid #050505;
  border-radius: 8px;
  background: #050505;
  color: #d97855;
  font-weight: 850;
  letter-spacing: 0;
  transform: translateY(0);
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.start-button:hover {
  background: transparent;
  color: #050505;
  transform: translateY(-2px);
}

body.start-cleared .start-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.launcher {
  transition: opacity 0.28s ease, transform 0.28s ease;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
  animation-timing-function: ease;
}

@keyframes page-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.launcher,
.app-shell {
  position: relative;
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 30px 0 48px;
}

.topbar,
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}

.hero {
  min-height: 230px;
  align-items: center;
}

.hero > *,
.topbar > * {
  max-width: 820px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  font-family: var(--font-ui);
}

.partner-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(217, 120, 85, 0.13);
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.partner-link:hover {
  background: rgba(217, 120, 85, 0.22);
}

.bgm-toggle {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 30;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(21, 21, 19, 0.86);
  color: var(--ink);
  font-weight: 850;
  box-shadow: var(--shadow);
}

.bgm-import {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px);
  z-index: 30;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(21, 21, 19, 0.86);
  color: var(--ink);
  font-weight: 850;
  box-shadow: var(--shadow);
}

.bgm-toggle.is-muted {
  border-color: var(--line);
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.05rem, 5vw, 4.85rem);
  line-height: 1.06;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 850;
  text-shadow: 0 3px 0 #000, 0 0 24px rgba(217, 120, 85, 0.14);
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.32rem, 2.4vw, 2.12rem);
}

h3 {
  font-size: 1rem;
}

p {
  color: var(--muted);
  line-height: 1.58;
}

.app-grid,
.panel-grid,
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.mobile-rich-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: 14px;
  margin: 18px 0;
}

.mobile-rich-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(125, 145, 98, 0.18), rgba(217, 120, 85, 0.09)),
    var(--panel);
  box-shadow: var(--shadow);
}

.mobile-rich-card h2 {
  margin-bottom: 8px;
  color: var(--ink);
}

.mobile-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.mobile-action-row a,
.mobile-action-row button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(217, 120, 85, 0.1);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-weight: 850;
}

.mobile-action-row a:hover,
.mobile-action-row button:hover {
  border-color: var(--line-strong);
  background: rgba(217, 120, 85, 0.16);
}

.mobile-feature-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-feature-list li {
  border: 1px solid rgba(217, 120, 85, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  line-height: 1.42;
}

.app-card,
.role-card,
.panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(244, 243, 238, 0.055), rgba(217, 120, 85, 0.035)),
    var(--panel);
  box-shadow: var(--shadow);
}

.app-card {
  position: relative;
  min-height: 216px;
  padding: 20px;
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
  will-change: transform;
}

button.app-card {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.role-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  margin: 0 0 18px;
}

.role-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  text-decoration: none;
  background:
    linear-gradient(135deg, rgba(125, 145, 98, 0.16), rgba(217, 120, 85, 0.08)),
    var(--panel);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.role-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
}

.role-card span {
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 900;
}

.role-card strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.role-card small {
  color: var(--muted);
  line-height: 1.4;
}

.admin-role {
  background:
    linear-gradient(135deg, rgba(217, 120, 85, 0.18), rgba(200, 61, 53, 0.1)),
    var(--panel);
}

.admin-grid {
  align-items: start;
}

.admin-status-panel,
.admin-tools-panel,
.admin-links-panel {
  padding: 20px;
}

.admin-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.admin-stat span {
  color: var(--muted);
}

.admin-stat strong {
  color: var(--gold);
}

.admin-actions,
.admin-link-list {
  display: grid;
  gap: 10px;
}

.admin-link-list a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.055);
}

.admin-link-list a:hover {
  border-color: var(--line-strong);
}

.danger-button {
  border: 1px solid rgba(255, 76, 76, 0.55);
  border-radius: 8px;
  padding: 11px 14px;
  background: rgba(255, 76, 76, 0.12);
  color: #ffd8d8;
  font-weight: 850;
}

.admin-note {
  margin: 14px 0 0;
  color: var(--muted);
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 5px solid var(--green);
  opacity: 0.92;
}

.app-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(217, 120, 85, 0.15), rgba(244, 243, 238, 0.045)),
    var(--panel-strong);
}

.app-card span {
  display: inline-flex;
  margin-bottom: 30px;
  color: var(--green);
  font-size: 0.86rem;
  font-weight: 800;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 12px;
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  transition: background 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

.back-link:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.toolbar,
.row,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(7, 7, 6, 0.72);
}

.toolbar input,
.toolbar select,
.input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(232, 238, 244, 0.96);
  color: #050505;
}

.toolbar input {
  min-width: min(420px, 100%);
  flex: 1;
}

.primary,
.secondary,
.danger {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary:hover,
.secondary:hover,
.danger:hover {
  transform: translateY(-1px);
}

.primary {
  border-color: rgba(217, 120, 85, 0.72);
  background: linear-gradient(180deg, var(--gold), #b86245);
  color: #151513;
}

.secondary {
  border-color: var(--line);
  background: rgba(244, 243, 238, 0.06);
  color: var(--ink);
}

.danger {
  background: linear-gradient(180deg, #ff8177, var(--red));
  color: white;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.stat-line span {
  color: var(--muted);
}

.stat-line strong {
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(217, 120, 85, 0.38);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(217, 120, 85, 0.14);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.panel,
.control-panel {
  padding: 18px;
}

@media (max-width: 780px) {
  html {
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    width: 100%;
    overflow-x: hidden;
  }

  .launcher,
  .app-shell {
    width: min(100vw - 20px, 760px);
    padding: 18px 0 max(32px, env(safe-area-inset-bottom));
  }

  .hero {
    min-height: auto;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.2rem);
  }

  p {
    line-height: 1.5;
  }

  .mobile-rich-panel {
    grid-template-columns: 1fr;
  }

  .mobile-action-row {
    grid-template-columns: 1fr;
  }

  .app-grid,
  .panel-grid,
  .role-grid {
    grid-template-columns: 1fr;
  }

  .app-card {
    min-height: 150px;
  }

  body.start-active {
    overflow: hidden;
  }

  .role-grid {
    grid-template-columns: 1fr;
  }

  .start-screen {
    gap: 14px;
    align-content: center;
    padding-block: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-bottom));
  }

  .start-mark {
    width: min(92vw, 520px);
  }

  .start-logo {
    max-height: min(42dvh, 360px);
  }

  .start-credits {
    border-top-width: 3px;
    font-size: clamp(0.68rem, 3.1vw, 0.9rem);
    line-height: 1.35;
  }

  .start-button {
    width: min(78vw, 280px);
    min-height: 52px;
    margin-bottom: max(4px, env(safe-area-inset-bottom));
  }

  .topbar,
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar input,
  .toolbar select,
  .toolbar button {
    width: 100%;
  }
}

@media (max-height: 620px) {
  .start-logo {
    max-height: 34dvh;
  }

  .start-mark {
    gap: 8px;
  }

  .start-credits {
    padding-top: 8px;
    font-size: 0.68rem;
  }

  .start-button {
    min-height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  body.is-entering,
  body.is-leaving,
  .app-card,
  .back-link,
  .primary,
  .secondary,
  .danger,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
    transition: none;
    filter: none;
  }
}

/* Global 8-bit presentation layer */
:root {
  --bg: #151513;
  --bg-2: #20201d;
  --ink: #f8f3d8;
  --muted: #c7c09a;
  --faint: #8f896b;
  --line: rgba(248, 243, 216, 0.28);
  --line-strong: rgba(255, 189, 89, 0.72);
  --panel: rgba(22, 24, 20, 0.94);
  --panel-strong: rgba(9, 10, 9, 0.98);
  --surface: rgba(248, 243, 216, 0.08);
  --surface-strong: rgba(255, 189, 89, 0.18);
  --green: #78c86b;
  --blue: #68aee8;
  --gold: #ffbd59;
  --red: #e04f44;
  --violet: #b78cff;
  --shadow: 6px 6px 0 #050505;
  --focus: 0 0 0 2px #050505, 0 0 0 5px #ffbd59;
  --font-ui: "Galmuri11", "DungGeunMo", "NeoDunggeunmo", "DOSGothic", "Courier New", "Malgun Gothic", monospace;
  --font-display: "Galmuri11", "DungGeunMo", "NeoDunggeunmo", "DOSGothic", "Courier New", "Malgun Gothic", monospace;
  --pixel-border: #050505;
}

html {
  image-rendering: pixelated;
}

body {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    linear-gradient(135deg, #151513 0%, #24301e 52%, #141411 100%);
  text-rendering: geometricPrecision;
}

body::before {
  background:
    linear-gradient(90deg, rgba(255, 189, 89, 0.12) 0 2px, transparent 2px 12px),
    linear-gradient(0deg, rgba(120, 200, 107, 0.08) 0 2px, transparent 2px 12px);
  mask-image: linear-gradient(180deg, black, transparent 70%);
}

img,
canvas,
svg,
.pokemon-art,
.caught-entry img,
.tool-entry img,
.rocket-fighter img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

canvas {
  filter: contrast(1.08) saturate(0.95);
}

h1,
h2,
h3,
.eyebrow,
button,
input,
select,
.badge,
.stat-line,
.app-card,
.role-card,
.panel,
.control-panel {
  font-family: var(--font-ui);
}

h1,
h2,
h3 {
  text-shadow: 3px 3px 0 #050505;
}

button,
input,
select,
textarea {
  border-radius: 0 !important;
  image-rendering: pixelated;
}

button {
  border-style: solid;
}

.start-screen {
  background:
    repeating-linear-gradient(0deg, rgba(5, 5, 5, 0.08) 0 2px, transparent 2px 10px),
    #7d9162;
}

.start-screen::after {
  background:
    linear-gradient(90deg, rgba(5, 5, 5, 0.08) 0 2px, transparent 2px 16px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.14), transparent 38%, rgba(0, 0, 0, 0.1));
}

.start-logo {
  image-rendering: pixelated;
  filter: contrast(1.08) saturate(1.12) drop-shadow(8px 8px 0 rgba(5, 5, 5, 0.24));
}

.start-logo-airtimno {
  image-rendering: auto;
  filter: drop-shadow(8px 8px 0 rgba(5, 5, 5, 0.18));
}

.app-card,
.role-card,
.panel,
.control-panel,
.mobile-rich-card,
.mobile-action-row a,
.mobile-action-row button,
.mobile-feature-list li,
.admin-stat,
.admin-link-list a,
.danger-button,
.back-link,
.toolbar,
.toolbar input,
.toolbar select,
.input,
.primary,
.secondary,
.danger,
.badge,
.partner-link,
.bgm-toggle,
.bgm-import,
.start-button {
  border-radius: 0 !important;
  border-width: 2px !important;
  box-shadow: var(--shadow) !important;
}

.app-card,
.role-card,
.panel,
.control-panel,
.mobile-rich-card,
.toolbar {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 10px),
    var(--panel) !important;
}

.app-card::before {
  border-top-width: 8px;
}

.primary,
.start-button {
  background: #ffbd59 !important;
  color: #050505 !important;
  border-color: var(--pixel-border) !important;
}

.secondary,
.back-link,
.bgm-toggle,
.bgm-import,
.mobile-action-row a,
.mobile-action-row button {
  background: #20201d !important;
  color: var(--ink) !important;
  border-color: var(--line-strong) !important;
}

.danger,
.danger-button {
  background: #e04f44 !important;
  color: #fff8e8 !important;
  border-color: var(--pixel-border) !important;
}

.primary:hover,
.secondary:hover,
.danger:hover,
.app-card:hover,
.role-card:hover,
.back-link:hover,
.mobile-action-row a:hover,
.mobile-action-row button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 #050505 !important;
}

.stat-line,
.topbar,
.hero {
  border-color: rgba(248, 243, 216, 0.32);
}

.arena-frame,
.world-modal-card,
.achievement-card,
.tutorial-card,
.rocket-battle-card,
.special-event-card,
.facility-celebration-card,
.mine-panel,
.stage-panel,
.rps-panel,
.clue-card,
.answer-panel,
.board-map,
.tile,
.facility-map,
.facility-zone,
.inventory-panel,
.ball-entry,
.tool-entry,
.caught-entry,
.rocket-choice,
.rocket-charge-panel {
  border-radius: 0 !important;
  box-shadow: var(--shadow) !important;
}

.arena-frame,
.world-modal-card,
.achievement-card,
.tutorial-card,
.rocket-battle-card,
.special-event-card {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 10px),
    #151513 !important;
}

.rocket-balloon,
.rocket-balloon-mark,
.rocket-basket,
.mobile-stick,
.mobile-stick-knob,
.mobile-actions button,
.facility-player-marker {
  border-radius: 0 !important;
}
