:root {
  color-scheme: dark;
  --ink: #09100d;
  --paper: #f1f4ef;
  --muted: #aab6ae;
  --line: rgba(241, 244, 239, 0.18);
  --lime: #cdea53;
  --cyan: #66cbd0;
  --coral: #ef7962;
  --focus: #ffd667;
  --header-height: 76px;
  --max: 1180px;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  color: var(--paper);
  background: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input { font: inherit; letter-spacing: 0; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.portal-body {
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto var(--header-height) minmax(0, 1fr);
}

/* Beta notice. Deliberately the first row of the page rather than something
   inside the hero: the portal does not scroll, so a strip above the header is
   the only place that is impossible to miss and never covers the artwork. */
.beta-banner {
  z-index: 11;
  padding: 9px max(22px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid rgba(205, 234, 83, 0.36);
  background: linear-gradient(90deg, rgba(239, 121, 98, 0.24), rgba(205, 234, 83, 0.2));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.beta-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--lime);
  color: #172005;
  font: 800 11px/1.6 Inter, system-ui, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.beta-banner p {
  max-width: 96ch;
  margin: 0;
  color: #f4f7f0;
  font-size: 14px;
  font-weight: 600;
}

.portal-header {
  z-index: 10;
  padding: 0 max(22px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 12, 9, 0.95);
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 22px;
}

.portal-brand img { width: 108px; height: auto; }

.portal-online {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(102, 203, 208, 0.34);
  border-radius: 4px;
  background: rgba(102, 203, 208, 0.08);
  display: flex;
  align-items: center;
  gap: 7px;
  color: #d7e7e5;
  font-size: 11px;
  white-space: nowrap;
}

.portal-online strong { color: var(--cyan); font-size: 13px; }

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(239, 121, 98, 0.18);
}

.state-dot.is-up { background: var(--lime); box-shadow: 0 0 0 4px rgba(205, 234, 83, 0.18); }
.state-dot.is-unavailable { background: #8d9991; box-shadow: 0 0 0 4px rgba(141, 153, 145, 0.18); }

.portal-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
}

.portal-nav a { color: #d5ddd7; font-size: 13px; font-weight: 800; }
.portal-nav a:hover { color: var(--lime); }

.portal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }

.language-switcher {
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(3, 31px);
  gap: 2px;
}

.language-switcher button {
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.language-switcher button.is-active { background: var(--lime); color: #172005; }

.portal-login {
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.portal-login:hover { border-color: var(--lime); color: var(--lime); }

.portal-main {
  min-height: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.portal-image,
.portal-shade { position: absolute; inset: 0; z-index: -2; }
.portal-image { background: url('/static/waxdofus-splash2.png') center 54% / cover no-repeat; }
.portal-shade { z-index: -1; background: rgba(4, 9, 15, 0.34); box-shadow: inset 0 -180px 150px rgba(5, 8, 11, 0.7); }

.portal-hero {
  width: min(var(--max), calc(100% - 38px));
  padding-bottom: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.portal-hero h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.portal-logo {
  width: min(660px, 72vw);
  height: auto;
  filter: drop-shadow(0 20px 34px rgba(0, 0, 0, 0.5));
}

.portal-hero > p {
  max-width: 760px;
  margin: -8px 0 0;
  color: #f3f5f2;
  font: 700 22px/1.45 Cinzel, serif;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.72);
}

.portal-ctas { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

.portal-button,
.form-submit,
.secondary-submit {
  min-height: 48px;
  padding: 0 19px;
  border: 1px solid transparent;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.portal-button-primary,
.form-submit { background: var(--lime); border-color: var(--lime); color: #172005; }
.portal-button-secondary,
.secondary-submit { border-color: rgba(255, 255, 255, 0.34); background: rgba(11, 20, 16, 0.62); color: #ffffff; }
.portal-button.is-disabled { opacity: 0.6; cursor: not-allowed; }

.portal-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 64px;
  padding: 12px max(22px, calc((100vw - var(--max)) / 2));
  border-top: 1px solid var(--line);
  background: rgba(7, 11, 10, 0.9);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  backdrop-filter: blur(12px);
}

.by-wax { font: 700 13px Cinzel, serif; }
.by-wax strong { color: var(--lime); }
.portal-footer p { margin: 0; color: #909b93; font-size: 10px; text-align: center; }

.discord-link {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #eef1ee;
  font-size: 12px;
  font-weight: 800;
}

.discord-link img {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.discord-link.is-disabled { opacity: 0.5; cursor: not-allowed; }

.account-dialog {
  width: min(470px, calc(100% - 24px));
  max-height: calc(100svh - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0e1712;
  color: var(--paper);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.6);
  /* hCaptcha expands its challenge iframe beyond the checkbox. A scrollable
     dialog clips that iframe below the modal, making the checkbox appear inert. */
  overflow: visible;
}

.account-dialog::backdrop { background: rgba(2, 6, 4, 0.76); backdrop-filter: blur(6px); }
.dialog-close { position: absolute; z-index: 2; top: 10px; right: 10px; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #141f19; color: var(--paper); cursor: pointer; font-size: 22px; }

.auth-tabs { height: 58px; padding: 5px 52px 5px 5px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.auth-tab { border: 0; border-radius: 3px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 800; font-size: 12px; }
.auth-tab.is-active { background: rgba(242, 244, 237, 0.1); color: var(--paper); }
.tab-panel,
.signed-in { padding: 27px 31px 22px; }
.panel-heading { margin-bottom: 22px; }
.panel-heading h2,
.signed-in h2 { margin: 0 0 6px; font: 700 24px/1.2 Cinzel, serif; }
.panel-heading p,
.signed-copy { margin: 0; color: var(--muted); font-size: 13px; }
.account-form { display: grid; gap: 14px; }
#registration-captcha { position: relative; z-index: 1; min-height: 78px; }
#registration-captcha iframe { position: relative; z-index: 2147483647; }
.account-form label { display: grid; gap: 7px; }
.account-form label > span { font-size: 12px; font-weight: 700; }
.account-form small { color: #929d95; font-size: 10px; line-height: 1.45; }

.account-form input {
  width: 100%;
  height: 44px;
  border: 1px solid rgba(242, 244, 237, 0.22);
  border-radius: 4px;
  padding: 0 13px;
  background: rgba(0, 0, 0, 0.26);
  color: var(--paper);
}

.account-form input::placeholder { color: #7b867f; }
.form-submit { width: 100%; margin-top: 2px; }
.form-message { margin: 0; padding: 10px 12px; border-radius: 4px; font-size: 12px; }
.registration-safety { border-left: 3px solid #e5bc68; background: rgba(229, 188, 104, 0.1); color: #f2dba9; line-height: 1.5; }
.form-message.is-error { border: 1px solid rgba(239, 121, 98, 0.5); background: rgba(239, 121, 98, 0.12); color: #ffc0b4; }
.security-note { margin: 0; padding: 14px 31px 17px; border-top: 1px solid var(--line); color: #8f9a92; font-size: 10px; text-align: center; }
.dialog-kicker { margin: 0 0 7px; color: var(--cyan); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.character-list { margin: 20px 0; display: grid; gap: 8px; }
.character-row { padding: 11px 13px; border: 1px solid var(--line); border-radius: 4px; display: flex; justify-content: space-between; gap: 16px; }
.character-row strong { font-size: 13px; }
.character-row span { color: var(--muted); font-size: 12px; }
.empty-characters { color: var(--muted); font-size: 13px; }
.signed-actions { display: grid; gap: 9px; }

@media (max-width: 900px) {
  :root { --header-height: 112px; }
  .beta-banner { padding: 8px 18px; gap: 9px; }
  .beta-banner p { font-size: 13px; }
  .portal-header { padding: 8px 18px; grid-template-columns: auto auto 1fr; grid-template-rows: 48px 40px; grid-template-areas: 'brand online actions' 'nav nav nav'; gap: 4px 12px; }
  .portal-brand { grid-area: brand; }
  .portal-online { grid-area: online; }
  .portal-nav { grid-area: nav; }
  .portal-actions { grid-area: actions; }
  .portal-logo { width: min(560px, 86vw); }
}

@media (max-width: 560px) {
  .beta-banner { padding: 7px 12px; gap: 7px; }
  .beta-badge { padding: 2px 8px; font-size: 10px; }
  .beta-banner p { font-size: 11.5px; line-height: 1.4; }
  .portal-header { padding-inline: 12px; grid-template-columns: auto auto 1fr; gap: 4px 8px; }
  .portal-brand img { width: 78px; }
  .portal-online { min-height: 34px; padding: 7px 8px; }
  .portal-online > span:last-child { display: none; }
  .language-switcher { display: none; }
  .portal-login { padding: 0 10px; }
  .portal-nav { gap: 22px; }
  .portal-nav a { font-size: 12px; }
  .portal-hero { width: calc(100% - 24px); padding-bottom: 72px; }
  .portal-logo { width: min(430px, 94vw); }
  .portal-hero > p { max-width: 31ch; margin-top: -2px; font-size: 15px; }
  .portal-ctas { width: 100%; margin-top: 24px; }
  .portal-button { width: min(320px, 100%); }
  .portal-footer { min-height: 64px; padding: 10px 12px; gap: 7px; }
  .portal-footer p { font-size: 8px; }
  .by-wax { font-size: 9px; }
  .discord-link { min-height: 34px; padding: 0 8px; font-size: 10px; }
  .tab-panel,
  .signed-in { padding: 25px 20px 20px; }
  .security-note { padding-inline: 20px; }
}

@media (max-height: 680px) and (min-width: 700px) {
  .portal-logo { width: min(480px, 60vw); }
  .portal-hero > p { font-size: 17px; }
  .portal-ctas { margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
