:root {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-soft: #111b2d;
  --panel: rgba(19, 28, 46, 0.94);
  --panel-strong: rgba(24, 37, 61, 0.96);
  --line: rgba(156, 176, 204, 0.22);
  --text: #e8f0fb;
  --muted: #9db0cc;
  --accent: #7cb3ff;
  --accent-strong: #f2c56b;
  --control: rgba(255, 255, 255, 0.06);
  --control-hover: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 54px rgba(0, 0, 0, 0.34);
  --radius: 4px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #d7e2f1;
  --bg-soft: #eef4fb;
  --panel: rgba(244, 248, 253, 0.95);
  --panel-strong: rgba(232, 240, 250, 0.96);
  --line: rgba(70, 98, 147, 0.2);
  --text: #172236;
  --muted: #556b8a;
  --accent: #3c74cb;
  --accent-strong: #a66f12;
  --control: rgba(248, 251, 255, 0.9);
  --control-hover: rgba(255, 255, 255, 1);
  --shadow: 0 24px 54px rgba(37, 64, 110, 0.14);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #d7e2f1;
    --bg-soft: #eef4fb;
    --panel: rgba(244, 248, 253, 0.95);
    --panel-strong: rgba(232, 240, 250, 0.96);
    --line: rgba(70, 98, 147, 0.2);
    --text: #172236;
    --muted: #556b8a;
    --accent: #3c74cb;
    --accent-strong: #a66f12;
    --control: rgba(248, 251, 255, 0.9);
    --control-hover: rgba(255, 255, 255, 1);
    --shadow: 0 24px 54px rgba(37, 64, 110, 0.14);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(124, 179, 255, 0.15), transparent 26rem),
    radial-gradient(circle at 84% 78%, rgba(242, 197, 107, 0.12), transparent 22rem),
    linear-gradient(135deg, var(--bg-soft), var(--bg));
}

.theme-button,
.theme-option,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.control-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.select-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-button,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--control);
}

select {
  max-width: min(38vw, 240px);
  padding: 0 34px 0 12px;
}

.theme-menu {
  position: relative;
}

.theme-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 132px;
  padding: 0 12px;
  cursor: pointer;
}

.theme-button:hover,
.theme-button:focus-visible,
select:hover,
select:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--control-hover);
}

.theme-icon {
  width: 1.1em;
  color: var(--accent);
  font-size: 0.92em;
  line-height: 1;
  text-align: center;
}

.theme-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  display: grid;
  min-width: 180px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
  box-shadow: var(--shadow);
}

.theme-options[hidden] {
  display: none;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.theme-option:hover,
.theme-option:focus-visible,
.theme-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.page-shell {
  display: grid;
  min-height: calc(100vh - 67px);
  place-items: center;
  padding: clamp(24px, 6vw, 72px) clamp(16px, 5vw, 72px);
}

.notice {
  position: relative;
  overflow: hidden;
  width: min(100%, 760px);
  padding: clamp(22px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, var(--panel), var(--panel-strong)),
    var(--panel);
  box-shadow: var(--shadow);
}

.notice::after {
  position: absolute;
  content: "\1F6E1";
  pointer-events: none;
  line-height: 1;
}

.notice::after {
  top: 18px;
  right: 22px;
  color: var(--accent-strong);
  font-size: clamp(1.5rem, 3vw, 3rem);
  opacity: 0.08;
}

.notice-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: clamp(18px, 4vw, 28px);
  align-items: start;
}

.notice-badge {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: var(--radius);
  color: var(--accent);
  background:
    radial-gradient(circle at 50% 22%, rgba(124, 179, 255, 0.18), transparent 64%),
    rgba(255, 255, 255, 0.035);
  font-size: 1.72rem;
  line-height: 1;
  animation: shield-settle 680ms ease-out both;
}

.notice-copy {
  position: relative;
  min-width: 0;
}

h1 {
  max-width: 18ch;
  margin: 0 0 18px;
  color: var(--text);
  font-size: clamp(1.7rem, 2vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.battle-quip {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.message-stack {
  display: grid;
  gap: 12px;
}

.message-block {
  max-width: 620px;
  padding: 2px 0 2px 16px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 44%, var(--line));
}

.message-block[hidden] {
  display: none;
}

.message-block p {
  margin: 0;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.55;
}

.context-note {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.battle-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, var(--accent-strong) 48%, var(--line));
  border-radius: var(--radius);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(242, 197, 107, 0.22), rgba(124, 179, 255, 0.1)),
    var(--control);
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.battle-link:hover,
.battle-link:focus-visible {
  border-color: var(--accent-strong);
  background:
    linear-gradient(180deg, rgba(242, 197, 107, 0.32), rgba(124, 179, 255, 0.14)),
    var(--control-hover);
}

html[dir="rtl"] .topbar,
html[dir="rtl"] .controls,
html[dir="rtl"] .brand {
  direction: rtl;
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    align-items: stretch;
    flex-direction: row;
  }

  .control-group {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-button {
    width: 100%;
  }

  .theme-options {
    width: 100%;
  }

  select {
    width: 100%;
    max-width: none;
  }
  .page-shell {
    min-height: auto;
    place-items: start;
  }

  h1 {
    max-width: 18ch;
  }
}

.retreat-link {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.retreat-link:hover,
.retreat-link:focus-visible {
  color: var(--text);
}

@media (max-width: 520px) {
  .notice-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .notice-badge {
    width: 44px;
    height: 44px;
    font-size: 1.35rem;
  }
}

@keyframes shield-settle {
  0% {
    opacity: 0;
    transform: translateY(-6px) scale(0.92);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notice-badge {
    animation: none;
  }
}
