:root {
  --brand-dark: #11100f;
  --deep-wine: #291314;
  --signature-gold: #c79a3c;
  --crown-gold: #e0b85a;
  --light-beam: #f7e8c7;
  --pearl: #f8f2e8;
  --ash: #a7a09a;
  --field-color: #11100f;
  --pulse-scale: 1;
  --pulse-glow: 0;
  --veil-alpha: 0.18;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--brand-dark);
  color: var(--pearl);
  font-family: Rubik, "Noto Sans Thai", "Noto Sans SC", "Noto Sans JP", Arial, Helvetica, sans-serif;
}

body {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  isolation: isolate;
  background: var(--brand-dark);
}

#fieldCanvas,
.ambient-shadow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#fieldCanvas {
  z-index: 0;
  display: block;
}

.ambient-shadow {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(17, 16, 15, 0.52), rgba(17, 16, 15, 0.04) 42%, rgba(17, 16, 15, 0.44)),
    linear-gradient(180deg, rgba(17, 16, 15, 0.3), rgba(17, 16, 15, 0) 38%, rgba(17, 16, 15, 0.5)),
    rgba(17, 16, 15, var(--veil-alpha));
}

.control-shell {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 28px;
}

.control-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 56px);
  max-height: calc(100svh - 56px);
  overflow: auto;
  padding: 32px;
  border: 1px solid rgba(224, 184, 90, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(17, 16, 15, 0.82), rgba(41, 19, 20, 0.58)),
    rgba(17, 16, 15, 0.72);
  box-shadow:
    0 0 calc(36px + (var(--pulse-glow) * 80px)) rgba(224, 184, 90, calc(0.16 + (var(--pulse-glow) * 0.22))),
    0 30px 90px rgba(0, 0, 0, 0.38);
  text-align: center;
  transform: scale(var(--pulse-scale));
  transform-origin: center;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.console-logo {
  display: block;
  width: min(128px, 34vw);
  height: auto;
  margin: 0 auto 18px;
  opacity: 0.92;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.32));
}

.language-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: min(360px, 100%);
  margin: 0 auto 18px;
  padding: 5px;
  border: 1px solid rgba(224, 184, 90, 0.5);
  border-radius: 999px;
  background: rgba(17, 16, 15, 0.62);
  box-shadow: inset 0 0 18px rgba(247, 232, 199, 0.06);
  backdrop-filter: blur(14px);
}

.language-option {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(248, 242, 232, 0.72);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.language-option:hover,
.language-option:focus-visible {
  color: var(--light-beam);
  outline: none;
}

.language-option.is-active {
  background: var(--crown-gold);
  color: var(--brand-dark);
}

.program-name {
  margin: 0 0 14px;
  color: var(--crown-gold);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 17ch;
  margin: 0 auto;
  color: var(--light-beam);
  font-size: 3.8rem;
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: 0;
  text-wrap: balance;
}

h1 span {
  display: block;
  white-space: nowrap;
}

html[lang="th"] h1,
html[lang="zh-Hans"] h1,
html[lang="ja"] h1 {
  max-width: 16ch;
  font-size: 3.25rem;
}

.brand-line {
  margin: 18px auto 0;
  color: rgba(248, 242, 232, 0.78);
  font-size: 1.05rem;
  line-height: 1.5;
}

.preplay-note {
  margin: 20px auto 0;
  padding: 16px 18px;
  border: 1px solid rgba(224, 184, 90, 0.28);
  border-radius: 8px;
  background: rgba(248, 242, 232, 0.065);
  color: rgba(248, 242, 232, 0.82);
  font-size: 0.92rem;
  line-height: 1.55;
  text-align: left;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 24px 0 24px;
}

.control-unit {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 96px;
  color: rgba(248, 242, 232, 0.8);
  font-size: 0.9rem;
  font-weight: 500;
}

.round-control {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  border: 1px solid rgba(247, 232, 199, 0.54);
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(224, 184, 90, 0.24), rgba(17, 16, 15, 0.32)),
    rgba(17, 16, 15, 0.58);
  color: var(--light-beam);
  cursor: pointer;
  box-shadow:
    inset 0 0 24px rgba(247, 232, 199, 0.1),
    0 12px 30px rgba(0, 0, 0, 0.32);
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.round-control:hover:not(:disabled),
.round-control:focus-visible {
  border-color: var(--crown-gold);
  box-shadow:
    inset 0 0 30px rgba(247, 232, 199, 0.18),
    0 0 34px rgba(224, 184, 90, 0.22),
    0 16px 34px rgba(0, 0, 0, 0.36);
  outline: none;
  transform: translateY(-1px);
}

.round-control:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.play-symbol {
  display: block;
  width: 0;
  height: 0;
  margin-left: 7px;
  border-top: 17px solid transparent;
  border-bottom: 17px solid transparent;
  border-left: 27px solid currentColor;
}

.stop-symbol {
  display: block;
  width: 27px;
  height: 27px;
  background: currentColor;
  border-radius: 2px;
}

.progress-shell {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(248, 242, 232, 0.16);
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--signature-gold), var(--light-beam));
  box-shadow: 0 0 22px rgba(224, 184, 90, 0.54);
  transition: width 120ms linear;
}

.readout {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  color: rgba(248, 242, 232, 0.72);
  font-size: 0.9rem;
  line-height: 1.4;
}

.about-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  margin-top: 22px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--light-beam);
  cursor: pointer;
}

.info-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(224, 184, 90, 0.68);
  border-radius: 50%;
  color: var(--crown-gold);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
}

.about-button span:last-child {
  font-size: 0.9rem;
  font-weight: 500;
}

.about-button:hover,
.about-button:focus-visible {
  color: var(--crown-gold);
  outline: none;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-layer[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 16, 15, 0.74);
  backdrop-filter: blur(18px);
}

.modal-panel {
  position: relative;
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  max-height: min(760px, calc(100svh - 48px));
  overflow: auto;
  padding: 34px;
  border: 1px solid rgba(224, 184, 90, 0.56);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(17, 16, 15, 0.96), rgba(41, 19, 20, 0.9)),
    var(--brand-dark);
  box-shadow:
    0 0 60px rgba(224, 184, 90, 0.18),
    0 34px 100px rgba(0, 0, 0, 0.54);
  outline: none;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(247, 232, 199, 0.32);
  border-radius: 50%;
  background: rgba(17, 16, 15, 0.52);
  color: rgba(248, 242, 232, 0.84);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.modal-close:hover,
.modal-close:focus-visible {
  border-color: var(--crown-gold);
  color: var(--crown-gold);
  outline: none;
}

.modal-logo {
  display: block;
  width: 104px;
  height: auto;
  margin: 0 auto 18px;
  opacity: 0.88;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.32));
}

.modal-eyebrow {
  margin: 0 0 10px;
  color: var(--crown-gold);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.modal-panel h2 {
  max-width: 12ch;
  margin: 0;
  color: var(--light-beam);
  font-size: 2.85rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

html[lang="th"] .modal-panel h2,
html[lang="zh-Hans"] .modal-panel h2,
html[lang="ja"] .modal-panel h2 {
  max-width: 16ch;
  font-size: 2.55rem;
}

.modal-intro {
  max-width: 680px;
  margin: 16px 0 0;
  color: rgba(248, 242, 232, 0.9);
  font-size: 1.05rem;
  line-height: 1.55;
}

.modal-note {
  max-width: 760px;
  margin: 16px 0 0;
  color: rgba(248, 242, 232, 0.74);
  font-size: 0.95rem;
  line-height: 1.6;
}

.phase-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0;
  color: var(--brand-dark);
}

.phase-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(247, 232, 199, 0.9);
  font-size: 0.82rem;
  font-weight: 700;
}

.phase-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-list li {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 14px;
  min-height: 138px;
  padding: 18px;
  border: 1px solid rgba(247, 232, 199, 0.13);
  border-radius: 8px;
  background: rgba(248, 242, 232, 0.055);
}

.phase-list li:last-child {
  grid-column: 1 / -1;
}

.phase-color {
  width: 16px;
  min-height: 100%;
  border-radius: 999px;
  background: var(--phase-color);
  box-shadow: 0 0 24px color-mix(in srgb, var(--phase-color), transparent 42%);
}

.phase-kicker {
  margin: 0 0 7px;
  color: var(--crown-gold);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
}

.phase-list h3 {
  margin: 0;
  color: var(--light-beam);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.25;
}

.phase-list p:last-child {
  margin: 8px 0 0;
  color: rgba(248, 242, 232, 0.72);
  font-size: 0.9rem;
  line-height: 1.45;
}

body.is-playing .control-panel {
  border-color: rgba(247, 232, 199, 0.62);
}

body.is-playing {
  cursor: pointer;
}

body.is-playing .ambient-shadow,
body.is-playing .control-shell,
body.is-playing .modal-layer {
  opacity: 0;
  pointer-events: none;
}

body.is-playing .control-shell,
body.is-playing .modal-layer {
  visibility: hidden;
}

@media (max-width: 720px) {
  .language-switch {
    margin-bottom: 16px;
  }

  .language-option {
    font-size: 0.72rem;
  }

  .control-shell {
    padding: 18px;
  }

  .control-panel {
    max-height: calc(100vh - 36px);
    max-height: calc(100svh - 36px);
    padding: 26px 20px;
  }

  .console-logo {
    width: 96px;
    margin-bottom: 14px;
  }

  h1 {
    font-size: 2.45rem;
  }

  h1[data-i18n-lines] {
    font-size: 2.25rem;
  }

  html[lang="th"] h1,
  html[lang="zh-Hans"] h1,
  html[lang="ja"] h1 {
    font-size: 2.1rem;
  }

  .brand-line {
    font-size: 0.98rem;
  }

  .preplay-note {
    margin-top: 16px;
    padding: 13px 14px;
    font-size: 0.84rem;
    line-height: 1.45;
  }

  .controls {
    gap: 16px;
    margin: 20px 0 20px;
  }

  .control-unit {
    min-width: 82px;
  }

  .round-control {
    width: 74px;
    height: 74px;
  }

  .readout {
    align-items: center;
    flex-direction: column;
    gap: 4px;
  }

  .modal-layer {
    padding: 14px;
  }

  .modal-panel {
    max-height: calc(100vh - 28px);
    max-height: calc(100svh - 28px);
    padding: 28px 18px 22px;
  }

  .modal-panel h2 {
    max-width: 11ch;
    font-size: 2.05rem;
  }

  html[lang="th"] .modal-panel h2,
  html[lang="zh-Hans"] .modal-panel h2,
  html[lang="ja"] .modal-panel h2 {
    max-width: 15ch;
    font-size: 1.78rem;
  }

  .modal-logo {
    width: 84px;
    margin-bottom: 14px;
  }

  .modal-intro {
    font-size: 0.98rem;
  }

  .modal-note,
  .phase-list p:last-child {
    font-size: 0.86rem;
  }

  .phase-summary {
    gap: 8px;
  }

  .phase-summary span {
    min-height: 30px;
    padding: 6px 10px;
    font-size: 0.76rem;
  }

  .phase-list {
    grid-template-columns: 1fr;
  }

  .phase-list li {
    min-height: auto;
    padding: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .control-panel,
  .round-control,
  .progress-fill {
    transition: none;
  }
}
