:root {
  color-scheme: dark;
  --page: #17151b;
  --surface: #211e27;
  --strong: #2d2935;
  --line: #484150;
  --ink: #f7f3ea;
  --muted: #aaa3af;
  --gold: #e9bd5e;
  --mint: #70c9b4;
  --coral: #ee806f;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}
button,
input {
  font: inherit;
  letter-spacing: 0;
}
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 8px clamp(12px, 3vw, 34px);
  background: #1b1820;
}
.back-link,
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 850;
}
.back-link {
  color: var(--muted);
  text-decoration: none;
}
.brand {
  justify-self: center;
}
.brand-mark {
  display: grid;
  min-width: 30px;
  height: 24px;
  place-items: center;
  border-radius: 4px;
  background: var(--gold);
  color: #211b18;
  font-size: 11px;
}
.header-actions {
  justify-self: end;
  display: flex;
  gap: 6px;
}
.language-button,
.header-button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--strong);
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
}
.language-button {
  width: 42px;
}
.header-button {
  padding: 0 10px;
}
.setup-screen,
.final-screen {
  width: min(940px, calc(100% - 36px));
  margin: auto;
  padding: clamp(42px, 7vw, 76px) 0;
}
.screen-heading {
  margin-bottom: 30px;
}
.screen-heading p,
.write-stage p,
.vote-stage p,
.result-stage p {
  margin: 0;
  color: var(--mint);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.screen-heading h1 {
  margin: 5px 0 8px;
  font-size: clamp(40px, 6vw, 64px);
  line-height: 1;
}
.screen-heading > span {
  color: var(--muted);
}
.setup-tool {
  border-top: 1px solid var(--line);
}
.add-form {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
.add-form label,
.setting > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}
.add-form > div {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 8px;
}
.add-form input,
#caption-input {
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--ink);
}
.add-button {
  border: 0;
  border-radius: 6px;
  background: var(--mint);
  font-size: 24px;
  font-weight: 900;
}
.roster {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-height: 84px;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.roster-item {
  display: grid;
  grid-template-columns: 38px 1fr 30px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: var(--surface);
}
.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #211b18;
  font-weight: 950;
}
.roster-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
}
.remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}
.settings-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding-top: 20px;
}
.setting {
  display: grid;
  gap: 8px;
}
.segments {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.segments button {
  width: 58px;
  height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}
.segments button.is-active {
  background: var(--mint);
  color: #17221f;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 17px;
  font-size: 13px;
  font-weight: 900;
}
.primary {
  background: var(--gold);
  color: #211b18;
}
.secondary {
  border-color: var(--line);
  background: var(--strong);
  color: var(--ink);
}
.button:disabled {
  opacity: 0.4;
}
.play-screen {
  padding-bottom: 82px;
}
.round-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 8px clamp(14px, 4vw, 48px);
  background: var(--surface);
}
.round-bar > div {
  display: flex;
  flex-direction: column;
}
.round-bar span {
  color: var(--mint);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.round-bar strong {
  color: var(--muted);
  font-size: 12px;
}
.battle-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.25fr) minmax(300px, 0.75fr);
  gap: 24px;
  width: min(1120px, calc(100% - 36px));
  margin: 24px auto;
}
.scene,
.history-scene {
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-color: var(--strong);
}
.scene {
  min-height: 500px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.write-stage,
.vote-stage,
.result-stage {
  display: grid;
  align-content: center;
  min-height: 500px;
}
.write-stage h1,
.vote-stage h1 {
  margin: 5px 0 24px;
  font-size: clamp(30px, 4vw, 45px);
  line-height: 1;
}
.write-stage form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}
.write-stage > span,
.result-stage > span {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}
.caption-list {
  display: grid;
  gap: 8px;
}
.caption-option {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 13px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-align: left;
}
.caption-option:hover {
  border-color: var(--gold);
}
.result-stage blockquote {
  margin: 10px 0;
  font-size: clamp(27px, 4vw, 45px);
  font-weight: 900;
  line-height: 1.08;
}
.result-stage strong {
  color: var(--gold);
  font-size: 17px;
}
.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  border-top: 1px solid var(--line);
  padding: 10px 20px;
  background: rgba(27, 24, 32, 0.97);
}
.action-bar > div {
  display: flex;
  flex-direction: column;
}
.action-bar span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}
.action-bar strong {
  font-size: 15px;
}
.action-bar .button span {
  color: inherit;
  font-size: 13px;
  text-transform: none;
}
.final-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.winner-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.winner-card .history-scene {
  aspect-ratio: 16/9;
}
.winner-card div:last-child {
  padding: 13px;
}
.winner-card strong {
  display: block;
  font-size: 16px;
}
.winner-card span {
  color: var(--gold);
  font-size: 12px;
}
.final-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
dialog {
  width: min(760px, calc(100% - 24px));
  max-height: 85vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--page);
  color: var(--ink);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}
dialog header {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}
dialog p {
  margin: 0;
  color: var(--mint);
  font-size: 10px;
  text-transform: uppercase;
}
dialog h2 {
  margin: 3px 0;
}
dialog header button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
}
.history-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px;
}
.history-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.history-scene {
  aspect-ratio: 16/9;
}
.history-item div:last-child {
  padding: 10px;
}
.history-item strong {
  display: block;
}
.history-item small {
  color: var(--gold);
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 82px;
  visibility: hidden;
}
.toast.show {
  visibility: visible;
}
@media (max-width: 720px) {
  .battle-layout {
    grid-template-columns: 1fr;
  }
  .scene {
    min-height: auto;
    aspect-ratio: 16/10;
  }
  .write-stage,
  .vote-stage,
  .result-stage {
    min-height: 260px;
  }
  .roster {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }
  .brand {
    font-size: 11px;
  }
  .header-button {
    width: 36px;
    overflow: hidden;
    padding: 0;
    color: transparent;
    font-size: 0;
  }
  .header-button::after {
    color: var(--gold);
    content: "★";
    font-size: 15px;
  }
  .setup-screen,
  .final-screen {
    width: calc(100% - 28px);
  }
  .add-form {
    grid-template-columns: 1fr;
  }
  .roster {
    grid-template-columns: 1fr;
  }
  .settings-row {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }
  .settings-row .button {
    width: 100%;
  }
  .battle-layout {
    width: calc(100% - 20px);
    margin-top: 12px;
  }
  .write-stage form {
    grid-template-columns: 1fr;
  }
  .final-list,
  .history-list {
    grid-template-columns: 1fr;
  }
  .round-bar .secondary {
    width: 44px;
    padding: 0;
  }
  .round-bar .secondary span:last-child {
    display: none;
  }
}
