/* Dialog tokens and layout based on NewWeb/docs/ui-standard.md. */
:root {
  --black: #050505;
  --panel: #0c0d0d;
  --panel-2: #151616;
  --line: #393a38;
  --text: #ecece8;
  --muted: #989a97;
  --pink: #ff18bb;
  --pink-soft: #ff72d3;
  --disabled-bg: #343535;
  --overlay: rgba(0, 0, 0, 0.78);
  --font-caption: 10px;
  --font-meta: 12px;
  --font-small: 14px;
  --font-body: 16px;
  --font-lead: 18px;
  --font-title: 20px;
  --dialog-width: 400px;
  --control-height: 44px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --modal-font: Arial, "Noto Sans TC", "PingFang TC", sans-serif;
}
.modal-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--overlay);
  overflow: hidden;
  font-family: var(--modal-font);
  color: var(--text);
}
.modal-card {
  width: min(100%, var(--dialog-width));
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
}
[data-page="fortunes"] .modal-card,
[data-page="m8b"] .modal-card {
  --dialog-width: 440px;
}
.modal-header {
  flex: 0 0 auto;
  min-height: 52px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.modal-header h2 {
  min-width: 0;
  margin: 0;
  font-family: var(--modal-font);
  font-size: var(--font-title);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.modal-header .modal-close {
  align-self: stretch;
  min-height: var(--control-height);
  padding: 0 12px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--font-small);
  text-align: right;
  white-space: nowrap;
  cursor: pointer;
}
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
.modal-header .modal-close:hover { color: var(--pink); }
}

.modal-body {
  min-width: 0;
  min-height: 0;
  padding: var(--space-5) var(--space-4);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-stack { display: grid; gap: var(--space-3); }
.modal-text {
  margin: 0;
  color: var(--text);
  font-size: var(--font-body);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.modal-text--muted { color: var(--muted); font-size: var(--font-meta); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.modal-actions .modal-button {
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--font-small);
  cursor: pointer;
}
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
.modal-actions .modal-button:hover:not(:disabled) { background: var(--panel-2); }
}

.modal-actions .modal-button--primary {
  border-color: var(--pink);
  background: var(--pink);
  color: #fff;
}
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
.modal-actions .modal-button--primary:hover:not(:disabled) {
  border-color: var(--pink-soft);
  background: var(--pink-soft);
}
}

.modal-actions .modal-button:disabled {
  border-color: var(--line);
  background: var(--disabled-bg);
  color: var(--muted);
  cursor: not-allowed;
}
.modal-card :focus-visible { outline-color: var(--pink); }
/* Preserve the fortune paper and eight-ball graphic within the shared shell. */
.modal-body .slip {
  width: min(100%, 380px);
  margin-inline: auto;
  max-height: none;
  overflow: visible;
  box-shadow: none;
  font-family: "Noto Serif TC", serif;
}
.modal-body .triangle-wrap { width: 100%; }
.modal-body .triangle { width: min(100%, 400px); }
.modal-body .triangle-text { font-size: clamp(20px, 5vw, 32px); }
@media (max-width: 648px), (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  .modal-overlay, .result-overlay {
    --font-meta: 13px;
    --font-small: 15px;
    --font-body: 17px;
    --control-height: 48px;
    padding: var(--space-2);
  }
  .modal-card { max-height: calc(100dvh - 16px); }
  .modal-header { min-height: 54px; }
  .modal-body { padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) {
  .modal-actions .modal-button { flex: 1; }
}

.menu-links {
  display: grid;
  gap: var(--space-2);
}
.menu-links a {
  display: grid;
  place-items: center;
  min-height: var(--control-height);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: var(--font-body);
  font-weight: 400;
}

.modal-text { text-align: center; }
#help-dialog .modal-header { grid-template-columns: minmax(0, 1fr); }
#help-dialog .modal-header > span { display: none; }
#help-dialog .modal-actions { justify-content: center; }
#help-dialog .modal-actions .modal-button { flex: 1; }

/* Keep the copyright visible in the page footer on mobile. */
@media (max-width: 768px), (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  .footer { display: block; }
  .mobile-menu .menu-copyright {
    flex: 0 0 auto;
    margin: 0;
    padding: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-family: var(--modal-font);
    font-size: 12px;
    line-height: 1.7;
    text-align: center;
  }
}
