/* Shared design tokens and components for the portal and every game. */
:root {
  --bg: #0e1024;
  --bg-2: #151838;
  --panel: rgba(24, 27, 60, 0.82);
  --panel-solid: #191c3e;
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef0ff;
  --muted: #a4a9d0;
  --accent: #ffd043; /* yuzu yellow: primary actions, progress */
  --accent-2: #35d6ee; /* cyan: focus, interface lines */
  --on-accent: #0a0d1c; /* text on --accent */
  --good: #46e0a0;
  --radius: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Shape of the shared controls. The default is the angular site look; a game with its own look resets these
   * in its :root, next to its colours (see games/zenith/zenith.css). */
  --btn-clip: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  --btn-focus-offset: -5px; /* a clipped corner would cut an outside ring, so it is drawn inside */
  --btn-ring-primary: var(--on-accent);
  --r-btn: 0;
  --r-ctl: 0;
  --r-input: 4px;
  --r-dlg: 6px;
  --r-chip: 0;
}

/* Font stacks per language: the <html lang> attribute also makes the browser pick the right Han glyph shapes
 * (Japanese, Simplified and Traditional Chinese share code points but draw them differently). */
:lang(ja) {
  --font: system-ui, 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', 'Noto Sans CJK JP', 'Noto Sans JP', sans-serif;
}
:lang(ko) {
  --font: system-ui, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans CJK KR', 'Noto Sans KR', sans-serif;
  word-break: keep-all;
}
:lang(zh-CN) {
  --font: system-ui, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', 'Noto Sans SC', sans-serif;
}
:lang(zh-TW) {
  --font: system-ui, 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans CJK TC', 'Noto Sans TC', sans-serif;
}
:lang(th) {
  --font: system-ui, 'Leelawadee UI', 'Noto Sans Thai', Tahoma, sans-serif;
}
:lang(vi) {
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
}

/* text is hidden only until its translation is applied (or 0.7 s at most); canvases and layout are never hidden */
html:not(.i18n-ready) [data-i18n],
html:not(.i18n-ready) [data-i18n-attr] {
  visibility: hidden;
}

.lang {
  appearance: none;
  max-width: 100%;
  padding: 8px 30px 8px 12px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a4a9d0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 10px center;
}
.lang option {
  background: #191c3e;
  color: #fff;
}

/* ---------- small buttons, chips, account bar ---------- */
.btn.small {
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: var(--r-ctl);
}
.btn.icon {
  padding: 8px 10px;
}
.btn.danger {
  background: rgba(255, 92, 120, 0.2);
  color: #ffb3c1;
}
.btn.danger:hover {
  background: rgba(255, 92, 120, 0.35);
}
.chip {
  display: inline-flex;
  align-items: center;
  max-width: 12em;
  padding: 7px 12px;
  border-radius: var(--r-chip);
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acct {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.linkbtn {
  appearance: none;
  background: none;
  border: 0;
  padding: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}
.linkbtn:hover {
  color: var(--text);
}

/* ---------- dialogs ---------- */
dialog.dlg {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-dlg);
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  overflow: auto;
}
dialog.dlg::backdrop {
  background: rgba(6, 7, 20, 0.7);
  backdrop-filter: blur(4px);
}
.dlg-body {
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dlg h2 {
  margin: 0;
  font-size: 1.35rem;
}
.dlg h3 {
  margin: 8px 0 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.dlg p {
  margin: 0;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.85rem;
  color: var(--muted);
}
.field small {
  color: var(--muted);
  font-size: 0.78rem;
}
.dlg input[type='text'],
.dlg input[type='password'] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-input);
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
}
.dlg input:focus {
  outline: none;
  border-color: var(--accent-2);
}
.dlg .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}
.err {
  min-height: 1.2em;
  color: #ff9db1;
  font-size: 0.88rem;
}
.status {
  min-height: 1.2em;
  color: var(--good);
  font-size: 0.85rem;
}
.keyrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.keybtn {
  min-width: 7em;
  padding: 8px 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: 700 0.95rem var(--font);
  cursor: pointer;
}
.keybtn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.keybtn.cap {
  border-color: var(--accent);
  background: rgba(255, 208, 67, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: var(--r-btn);
  clip-path: var(--btn-clip);
  padding: 14px 22px;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.btn:active {
  transform: scale(0.97);
}
.btn:focus-visible {
  outline-offset: var(--btn-focus-offset);
}
.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.primary:focus-visible {
  outline-color: var(--btn-ring-primary);
}
.btn[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.logo {
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--accent);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--line);
  font: 600 0.85em var(--font);
  text-align: center;
}

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