* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--ink-950);
}

body {
  min-height: 100svh;
  overflow: hidden;
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

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

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 15%, rgba(126, 33, 52, 0.12), transparent 35%),
    var(--ink-950);
}

.paper-grain {
  position: fixed;
  z-index: 100;
  inset: 0;
  pointer-events: none;
  opacity: 0.055;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, #fff 4px),
    repeating-linear-gradient(90deg, transparent 0 7px, #fff 8px);
  background-size: 5px 5px, 9px 9px;
  mix-blend-mode: soft-light;
}

.global-header {
  position: relative;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 clamp(18px, 3.2vw, 58px);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(10, 12, 19, 0.97), rgba(20, 23, 34, 0.9)),
    var(--ink-900);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}

.global-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 34%;
  height: 2px;
  background: linear-gradient(90deg, var(--crimson), transparent);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 226, 160, 0.5);
  background: linear-gradient(145deg, var(--crimson), var(--crimson-dark));
  box-shadow: inset 0 0 0 3px rgba(10, 10, 16, 0.45);
  color: #fff6e7;
  font: 700 25px/1 var(--serif);
  transform: rotate(-3deg);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font: 600 18px/1.2 var(--serif);
  letter-spacing: 0.16em;
}

.brand-copy small,
.eyebrow {
  color: var(--gold);
  font: 600 10px/1.2 var(--sans);
  letter-spacing: 0.3em;
}

.profile-strip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-chip {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0 9px;
  min-width: 88px;
  padding: 8px 12px;
  border-left: 1px solid var(--line);
}

.lang-select-wrap {
  display: flex;
  align-items: center;
}

select.profile-chip.lang-select {
  display: block;
  min-width: 96px;
  height: 38px;
  padding: 6px 24px 6px 10px;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 1px solid var(--line);
  background: rgba(18, 14, 24, 0.75);
  color: var(--paper-soft);
  font: 500 13px/1 var(--serif);
  letter-spacing: 0.08em;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23d8b66a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border-radius: 4px;
  transition: all 180ms ease;
}

select.profile-chip.lang-select:hover,
select.profile-chip.lang-select:focus {
  background-color: rgba(216, 182, 106, 0.15);
  color: var(--gold-bright);
  outline: none;
  border-color: var(--gold);
}

select.profile-chip.lang-select option {
  background: #14121a;
  color: #fff;
  font-size: 13px;
  padding: 8px;
}

.profile-chip small {
  color: var(--paper-dim);
  font-size: 9px;
  letter-spacing: 0.15em;
}

.profile-chip b {
  grid-row: 1 / 3;
  grid-column: 2;
  font: 500 17px/1 var(--serif);
}

.profile-xp {
  grid-template-columns: 44px minmax(90px, 10vw);
}

.profile-xp b {
  grid-row: 2;
  grid-column: 1;
  color: var(--paper-dim);
  font: 500 9px/1 var(--sans);
}

.micro-meter {
  position: relative;
  grid-row: 1 / 3;
  grid-column: 2;
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.micro-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #fff2c7);
  box-shadow: 0 0 8px var(--gold);
  transition: width 350ms ease;
}

.coin-chip b::before,
.large-wallet b::before {
  content: "✦";
  margin-right: 6px;
  color: var(--gold);
  font-size: 0.72em;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--gold-bright);
  cursor: pointer;
  transition: 160ms ease;
}

.icon-button:hover {
  border-color: var(--gold);
  background: rgba(216, 182, 106, 0.1);
}

.screen-stack {
  position: relative;
  height: calc(100svh - var(--header-height));
}

.screen {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: none;
  min-height: 0;
}

.screen.is-active {
  display: block;
  z-index: 2;
}

.text-button {
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--paper-dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.text-button:hover {
  color: var(--paper);
}

.button-primary,
.button-secondary {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
  box-shadow: inset 0 0 0 2px rgba(10, 10, 14, 0.35), 0 10px 28px rgba(0, 0, 0, 0.25);
  color: #fff9ef;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.button-secondary {
  border-color: var(--line);
  background: rgba(12, 14, 22, 0.82);
  color: var(--paper);
}

.button-primary:hover,
.button-secondary:hover {
  filter: brightness(1.16);
  transform: translateY(-2px);
}

.button-primary:disabled,
.button-secondary:disabled {
  opacity: 0.4;
  filter: grayscale(1);
  pointer-events: none;
}

.toast {
  position: fixed;
  z-index: 300;
  left: 50%;
  bottom: 28px;
  max-width: min(90vw, 520px);
  padding: 13px 20px;
  border: 1px solid var(--gold);
  background: rgba(12, 14, 22, 0.96);
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.5);
  color: var(--paper);
  font-size: 13px;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-tone="danger"] {
  border-color: var(--crimson-bright);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--ink-950);
}

::-webkit-scrollbar-thumb {
  background: var(--ink-700);
  border: 2px solid var(--ink-950);
}

/* App Footer - Endless Alice Steam Link */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 20px;
  background: rgba(10, 8, 14, 0.85);
  border-top: 1px solid rgba(216, 182, 106, 0.2);
  margin-top: auto;
}

.footer-game-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: linear-gradient(135deg, rgba(30, 20, 45, 0.9), rgba(15, 12, 25, 0.95));
  border: 1px solid rgba(216, 182, 106, 0.35);
  border-radius: 24px;
  color: var(--paper-soft);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 220ms ease;
}

.footer-game-link:hover {
  background: linear-gradient(135deg, rgba(60, 35, 90, 0.95), rgba(35, 20, 55, 0.98));
  border-color: var(--gold-bright);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(216, 182, 106, 0.25);
}

.footer-link-icon {
  font-size: 16px;
}

.footer-link-name {
  font: 700 14px/1 var(--serif);
  color: var(--gold-bright);
  letter-spacing: 0.08em;
}

.footer-link-desc {
  color: var(--paper-dim);
  font-size: 12px;
}

.footer-link-badge {
  padding: 2px 8px;
  background: #171a21;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #66c0f4;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.footer-game-link:hover .footer-link-badge {
  background: #66c0f4;
  color: #171a21;
  border-color: #66c0f4;
}

.debug-panel {
  position: fixed;
  z-index: 999;
  right: 8px;
  bottom: 8px;
  padding: 5px;
  border: 1px solid #7e688d;
  background: rgba(8, 8, 12, 0.94);
  color: #cab6d8;
  font: 10px/1.3 monospace;
}

.debug-panel summary {
  cursor: pointer;
}

.debug-panel button {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 4px 7px;
  border: 1px solid #5d4b68;
  background: #1b1520;
  color: inherit;
  cursor: pointer;
}
