:root {
  color-scheme: light;
  --paper: #f4efe3;
  --paper-deep: #eae1d0;
  --ink: #26372f;
  --muted: #5e6b62;
  --green: #274d3d;
  --green-deep: #1c382d;
  --gold: #ad7c3f;
  --vermillion: #a8543d;
  --line: #d7cdbc;
  --white: #fffdf8;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
}

body,
button {
  font-size: 1rem;
}

a {
  color: var(--green-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--vermillion);
}

button {
  font: inherit;
}

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

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

img,
iframe {
  max-width: 100%;
}

.skip-link {
  position: fixed;
  z-index: 50;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.35rem;
  background: var(--green-deep);
  color: var(--white);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  min-height: 4.25rem;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 2rem;
  height: 2rem;
  flex: none;
}

.brand small {
  display: block;
  margin-top: 0.22rem;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 400;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.site-nav a,
.language-switcher a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border-radius: 0.35rem;
  color: var(--ink);
  font-size: 0.9rem;
  text-decoration: none;
}

.site-nav a:hover,
.language-switcher a:hover,
.language-switcher a[aria-current="page"] {
  background: var(--paper-deep);
  color: var(--green-deep);
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--line);
}

.language-switcher a {
  color: var(--muted);
  font-size: 0.82rem;
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.temple-section {
  padding: clamp(1rem, 2.5vw, 2rem) 0 0;
  scroll-margin-top: 5rem;
}

.game-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.eyebrow,
.game-label {
  margin: 0;
  color: var(--vermillion);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", "Noto Serif", serif;
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  max-width: 36ch;
  margin: 0.25rem 0 0;
  color: var(--green-deep);
  font-size: clamp(1.5rem, 2.8vw, 2.4rem);
}

.game-heading-note {
  max-width: 30rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-shell {
  overflow: hidden;
  border: 1px solid #bdc1b5;
  border-radius: 0.65rem;
  background: #24251f;
  box-shadow: 0 0.9rem 2.6rem rgba(41, 53, 45, 0.12);
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.75rem 0.25rem 1rem;
  background: #e8eadf;
  color: var(--ink);
  font-size: 0.84rem;
}

.toolbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.35rem;
}

.records-button,
.account-button,
.fullscreen-button,
.records-toolbar button,
.records-actions button,
.records-private button {
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--green);
  border-radius: 0.35rem;
  background: var(--white);
  color: var(--green-deep);
  cursor: pointer;
}

.records-button:hover,
.account-button:hover,
.fullscreen-button:hover,
.records-toolbar button:hover,
.records-actions button:hover,
.records-private button:hover {
  background: var(--paper-deep);
}

#records-dlg,
#account-dlg {
  width: min(720px, calc(100% - 1.1rem));
  max-height: min(90svh, 760px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1.2rem 3rem rgba(41, 53, 45, 0.24);
  overflow-y: auto;
}

#records-dlg::backdrop,
#account-dlg::backdrop {
  background: rgba(28, 56, 45, 0.3);
}

#records-dlg > header,
#account-dlg > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

#records-dlg > header h2,
#account-dlg > header h2 {
  margin: 0;
  font-size: 1.25rem;
}

#records-dlg > header .close,
#account-dlg > header .close {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.2rem;
}

#records-dlg > :not(header),
#account-dlg > :not(header) {
  margin-right: 0.9rem;
  margin-left: 0.9rem;
}

#account-dlg {
  max-width: 32rem;
}

.account-status {
  min-height: 2.2rem;
  margin-top: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--green-deep);
}

.account-status[data-state="error"] {
  color: var(--vermillion);
}

.account-error {
  margin-top: 0.2rem;
  color: var(--vermillion);
}

.account-name {
  margin-top: 0;
  color: var(--muted);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.6rem 0 1rem;
}

.account-actions button,
#account-current {
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--green);
  border-radius: 0.35rem;
  background: var(--white);
  color: var(--green-deep);
  cursor: pointer;
}

.account-actions button:disabled,
#account-current:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.records-summary {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.records-summary h3,
.records-private h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.records-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.records-summary-grid p {
  min-width: 0;
  margin: 0;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: rgba(255, 253, 248, 0.68);
}

.records-summary-grid span,
.records-summary-grid strong {
  display: block;
}

.records-summary-grid span {
  color: var(--muted);
  font-size: 0.78rem;
}

.records-summary-grid strong {
  font-size: 0.95rem;
  line-height: 1.45;
}

.records-summary-grid strong + strong::before {
  content: ' · ';
  color: var(--muted);
}

.records-waiting {
  margin: 0.55rem 0 0;
  color: var(--vermillion);
  font-size: 0.86rem;
}

.records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.8rem;
}

.records-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.records-tabs button[aria-selected="true"] {
  background: var(--green);
  color: var(--white);
}

.records-status,
.records-updated {
  margin-top: 0.55rem;
  margin-bottom: 0;
}

.records-status[data-state="error"] {
  color: var(--vermillion);
}

.records-list {
  display: grid;
  gap: 0.45rem;
  max-height: 32svh;
  margin-top: 0.7rem;
  margin-bottom: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.records-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: rgba(255, 253, 248, 0.72);
}

.records-item-main,
.records-item-meta {
  min-width: 0;
}

.records-item-main strong,
.records-item-main span,
.records-item-meta span {
  display: block;
}

.records-item-main strong {
  font-size: 0.92rem;
}

.records-item-main span,
.records-item-meta span {
  color: var(--muted);
  font-size: 0.82rem;
}

.records-item-meta {
  flex: none;
  text-align: right;
}

.records-lamp-button {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.records-lamp-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.records-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 0;
}

.records-empty {
  margin-top: 0.8rem;
  margin-bottom: 0;
}

.records-private {
  margin-top: 0.7rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.records-private-wish {
  max-height: 10rem;
  margin: 0;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--white);
  white-space: pre-wrap;
  overflow-y: auto;
}

.frame-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.frame-status[hidden] {
  display: none;
}

.frame-status::before {
  width: 0.55rem;
  height: 0.55rem;
  flex: none;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.frame-status[data-state="online"],
.frame-status[data-state="ready"] {
  color: var(--green-deep);
}

.frame-status[data-state="online"]::before,
.frame-status[data-state="ready"]::before {
  background: #4f805b;
}

.frame-status[data-state="offline"],
.frame-status[data-state="error"] {
  color: var(--vermillion);
}

.frame-status[data-state="offline"]::before,
.frame-status[data-state="error"]::before {
  background: var(--vermillion);
}

.temple-frame {
  display: block;
  width: 100%;
  height: clamp(440px, 80svh, 960px);
  border: 0;
  background: #24251f;
}

.game-shell[data-fullscreen-mode="native"],
.game-shell[data-fullscreen-mode="fallback"] {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

.game-shell[data-fullscreen-mode="fallback"] {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

body.site-fullscreen-open {
  overflow: hidden;
}

.game-shell[data-fullscreen-mode="native"] .game-toolbar,
.game-shell[data-fullscreen-mode="fallback"] .game-toolbar,
.game-shell[data-fullscreen-mode="native"] .frame-error,
.game-shell[data-fullscreen-mode="fallback"] .frame-error {
  flex: 0 0 auto;
}

.game-shell[data-fullscreen-mode="native"] .temple-frame,
.game-shell[data-fullscreen-mode="fallback"] .temple-frame {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.frame-error {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.1rem 1.1rem;
  background: #f4e8df;
  color: #542e27;
}

.frame-error[hidden] {
  display: none;
}

.frame-error h2,
.frame-error p {
  margin: 0;
}

.frame-error h2 {
  font-family: inherit;
  font-size: 1rem;
}

.frame-error p {
  margin-top: 0.2rem;
  font-size: 0.9rem;
}

.retry-button {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid #8d493c;
  border-radius: 0.35rem;
  background: var(--vermillion);
  color: #fffaf4;
  cursor: pointer;
  white-space: nowrap;
}

.retry-button:hover {
  background: #8d493c;
}

.game-caption {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(2.5rem, 6vw, 5rem) clamp(2rem, 7vw, 6rem);
  padding: clamp(4rem, 8vw, 7rem) 0 4rem;
}

.content-section {
  min-width: 0;
  scroll-margin-top: 5rem;
}

.content-section.intro,
.content-section.faq-section,
.back-to-temple {
  grid-column: 1 / -1;
}

.content-section.intro {
  max-width: 54rem;
}

.section-kicker {
  margin: 0 0 0.3rem;
  color: var(--vermillion);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  margin: 0 0 0.8rem;
  color: var(--green-deep);
  font-size: clamp(1.45rem, 2.3vw, 2rem);
}

.content-section p {
  max-width: 64ch;
  margin: 0;
}

.steps {
  display: grid;
  gap: 0;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: steps;
}

.steps li {
  position: relative;
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.8rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  counter-increment: steps;
}

.steps li::before {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  content: counter(steps);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.steps h3 {
  margin: 0;
  color: var(--green-deep);
  font-size: 1.05rem;
}

.steps p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.94rem;
}

.faq-list {
  display: grid;
  border-top: 1px solid var(--line);
}

details {
  border-bottom: 1px solid var(--line);
}

summary {
  min-height: 48px;
  padding: 0.85rem 2rem 0.85rem 0;
  color: var(--green-deep);
  cursor: pointer;
  font-weight: 700;
  list-style-position: outside;
}

details p {
  padding: 0 2rem 1rem 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.back-to-temple {
  margin: 0;
  padding-top: 0.4rem;
  text-align: center;
}

.back-to-temple a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  color: var(--green-deep);
  text-decoration: none;
}

.back-to-temple a:hover {
  background: var(--paper-deep);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.3rem 0 2rem;
}

.footer-inner p {
  margin: 0;
}

@media (max-width: 820px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 0.2rem 0.8rem;
    padding: 0.35rem 0;
  }

  .site-nav {
    width: 100%;
    margin-left: 0;
    padding-bottom: 0.25rem;
    overflow-x: auto;
  }

  .language-switcher {
    margin-left: auto;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .content-section.intro,
  .content-section.faq-section,
  .back-to-temple {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .header-inner,
  main,
  .footer-inner {
    width: min(100% - 1.1rem, 1180px);
  }

  .header-inner {
    padding-top: 0;
    padding-bottom: 0;
  }

  .brand small {
    display: none;
  }

  .language-switcher {
    padding-left: 0.25rem;
  }

  .language-switcher a {
    padding-right: 0.4rem;
    padding-left: 0.4rem;
  }

  .game-heading {
    display: block;
    margin-bottom: 0.5rem;
  }

  .game-heading-note {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .temple-section {
    padding-top: 0.5rem;
  }

  h1 {
    max-width: none;
    font-size: clamp(1.375rem, 6vw, 1.625rem);
    line-height: 1.2;
  }

  .game-toolbar {
    min-height: 2.25rem;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 0.75rem;
  }

  .toolbar-actions {
    max-width: 52%;
    justify-content: flex-end;
  }

  .records-button,
  .account-button {
    flex: 0 1 auto;
    max-width: 48%;
    padding-right: 0.55rem;
    padding-left: 0.55rem;
    font-size: 0.8rem;
    white-space: normal;
  }

  .account-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .account-actions button,
  #account-current {
    width: 100%;
  }

  .records-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .records-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .records-tabs {
    width: 100%;
  }

  .records-tabs button {
    flex: 1 1 0;
    min-width: 0;
    padding-right: 0.45rem;
    padding-left: 0.45rem;
    white-space: normal;
  }

  .records-refresh {
    align-self: flex-start;
  }

  .frame-error {
    grid-template-columns: 1fr;
  }

  .retry-button {
    width: 100%;
  }

  .footer-inner {
    display: block;
  }

  .footer-inner p + p {
    margin-top: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* One-time support panel */
.support-button {
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--gold);
  border-radius: 0.35rem;
  background: var(--white);
  color: var(--green-deep);
  cursor: pointer;
}

.support-button:hover {
  background: var(--paper-deep);
}

#support-dlg {
  width: min(720px, calc(100% - 1.1rem));
  max-height: min(90svh, 760px);
  margin: auto;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1.2rem 3rem rgba(41, 53, 45, 0.24);
  overflow-y: auto;
}

#support-dlg::backdrop {
  background: rgba(28, 56, 45, 0.3);
}

#support-dlg > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: -0.9rem -0.9rem 0.9rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

#support-dlg > header h2 {
  margin: 0;
  font-size: 1.25rem;
}

#support-dlg .support-note,
#support-dlg .support-status,
#support-dlg .support-order-status {
  color: var(--muted);
}

#support-dlg label {
  display: block;
  margin-top: 0.7rem;
  font-weight: 600;
}

.support-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.8rem 0 0.45rem;
}

.support-amounts button,
.support-actions button,
.support-continue {
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--green);
  border-radius: 0.35rem;
  background: var(--white);
  color: var(--green-deep);
  cursor: pointer;
}

.support-amounts button[aria-pressed="true"] {
  background: var(--green);
  color: var(--white);
}

.support-amount {
  width: min(16rem, 100%);
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--white);
  color: var(--ink);
}

.support-error {
  color: var(--vermillion);
}

.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.8rem 0;
}

.support-actions button:first-child {
  border-color: var(--green-deep);
  background: var(--green);
  color: var(--white);
}

.support-actions button:disabled,
.support-amounts button:disabled,
.support-amount:disabled {
  cursor: wait;
  opacity: 0.6;
}

.support-checkout {
  min-height: 24rem;
  margin: 0.9rem 0;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--white);
}

.support-orders {
  margin-top: 1.2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.support-orders h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.support-orders ul {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.support-order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.support-continue {
  flex: none;
}

@media (max-width: 600px) {
  .game-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .frame-status,
  .toolbar-actions {
    flex: 1 1 100%;
  }

  .toolbar-actions {
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .toolbar-actions .records-button,
  .toolbar-actions .account-button,
  .toolbar-actions .fullscreen-button,
  .toolbar-actions .support-button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    max-width: none;
    padding-right: 0.45rem;
    padding-left: 0.45rem;
    white-space: normal;
  }

  .support-order-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .support-continue {
    width: 100%;
  }
}
