:root {
  --bg: #f3ead8;
  --surface: #fff8e8;
  --surface-strong: #fffdf5;
  --ink: #2f2921;
  --muted: #786d5f;
  --line: #d8bea1;
  --blue: #3d6f8f;
  --green: #5b8a72;
  --yellow: #d99b31;
  --red: #bf5a4f;
  --paper-shadow: rgba(79, 58, 32, 0.16);
  --tape-blue: #d8ecf2;
  --tape-pink: #f5d8d0;
  --tape-yellow: #f5dda2;
  --tape-green: #dcebd2;
  --grid-line: rgba(129, 101, 65, 0.1);
  --shadow: 0 14px 28px var(--paper-shadow);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18px 18px, rgba(61, 111, 143, 0.08) 1px, transparent 1.5px) 0 0 / 28px 28px,
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 100% 31px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 31px 100%,
    var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-width: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.liuzi-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px))
    env(safe-area-inset-bottom, 0px) max(14px, env(safe-area-inset-left, 0px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px 0 12px;
}

.brand,
.home-link {
  color: inherit;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.host-player-profile {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 9px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px 7px 7px;
  background: rgba(255, 253, 245, 0.88);
  box-shadow: 3px 3px 0 rgba(47, 41, 33, 0.08);
  font-size: 13px;
  font-weight: 800;
}

.host-player-profile img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #bb8f68;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--tape-yellow), #fff1bd);
  color: var(--blue);
  font-weight: 900;
  box-shadow: 3px 3px 0 rgba(61, 111, 143, 0.16);
  transform: rotate(-2deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.save-pill,
.home-link,
.eyebrow,
.lead,
.panel-footer,
.role-preview,
.profile-story,
.event-panel p,
.log-item,
.todo-list {
  color: var(--muted);
}

.top-actions,
.button-row,
.home-secondary-actions,
.home-tertiary-actions,
.quick-stats,
.panel-heading,
.panel-heading-actions,
.player-card,
.profile-hero {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 10px;
}

.home-secondary-actions,
.home-tertiary-actions {
  flex-wrap: wrap;
  gap: 10px;
}

.home-secondary-actions {
  margin-top: 12px;
}

.home-tertiary-actions {
  margin-top: 10px;
}

.save-pill,
.home-link {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)),
    var(--tape-blue);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(47, 41, 33, 0.08);
}

.liuzi-main {
  min-height: 0;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 0 24px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.home-layout,
.setup-layout,
.game-layout {
  display: grid;
  gap: 16px;
}

.home-layout {
  grid-template-columns: minmax(0, 900px);
  justify-content: center;
  min-height: min(720px, calc(100dvh - 104px));
}

.setup-layout,
.game-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.setup-layout.setup-linear {
  grid-template-columns: minmax(0, 900px);
  justify-content: center;
}

.game-layout {
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: min(760px, calc(100dvh - 104px));
}

.home-copy,
.collection-panel,
.setup-main,
.setup-side,
.profile-layout,
.status-column,
.week-column,
.ending-layout,
.about-game {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(216, 190, 161, 0.16) 1px, transparent 1px) 24px 0 / 28px 100%,
    linear-gradient(rgba(61, 111, 143, 0.08) 1px, transparent 1px) 0 16px / 100% 32px,
    rgba(255, 248, 232, 0.96);
  box-shadow: var(--shadow);
}

.home-copy,
.collection-panel,
.setup-main,
.setup-side,
.profile-layout,
.status-column,
.week-column,
.ending-layout {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  padding: 22px;
}

.home-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
}

.home-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: 46px;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.lead {
  max-width: 680px;
  font-size: 17px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quick-stats {
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 20px;
}

.quick-stats span,
.stat-card,
.ending-card,
.program-card,
.role-card,
.profile-item,
.mode-option,
.choice,
.passive-item,
.delta-pill,
.achievement {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 251, 237, 0.72)),
    var(--surface-strong);
  box-shadow: 3px 3px 0 rgba(95, 72, 43, 0.08);
}

.quick-stats span {
  padding: 10px 12px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0)),
    var(--tape-yellow);
}

.quick-stats strong {
  color: var(--blue);
}

.button-row {
  flex-wrap: wrap;
  gap: 10px;
}

.button-row.end {
  justify-content: flex-end;
}

.button-row.center {
  justify-content: center;
}

.btn {
  min-height: 42px;
  max-width: 100%;
  border: 1px solid rgba(99, 74, 42, 0.28);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  white-space: normal;
  box-shadow: 3px 3px 0 rgba(47, 41, 33, 0.12);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.btn.primary {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    #3d6f8f;
  color: #fffdf5;
}

.btn.secondary {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0)),
    #5b8a72;
  color: #fffdf5;
}

.btn.ghost {
  border-color: var(--line);
  background: rgba(255, 253, 245, 0.64);
  color: var(--ink);
}

.home-tertiary-actions .home-link {
  min-height: 34px;
  padding: 7px 9px;
  background: rgba(255, 253, 245, 0.56);
  font-size: 12px;
  box-shadow: 2px 2px 0 rgba(47, 41, 33, 0.06);
}

.mode-field {
  display: grid;
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
}

.mode-field legend {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.mode-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
  background:
    linear-gradient(90deg, rgba(245, 216, 208, 0.32), transparent 46%),
    var(--surface-strong);
}

.mode-option input {
  margin-top: 4px;
  accent-color: var(--blue);
}

.mode-option strong,
.mode-option small {
  display: block;
}

.mode-option small {
  color: var(--muted);
  line-height: 1.45;
}

.gender-field {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gender-field legend {
  grid-column: 1 / -1;
}

.mode-pill {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tape-green);
  padding: 6px 9px;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 800;
  box-shadow: 2px 2px 0 rgba(47, 41, 33, 0.08);
}

.mode-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mode-toggle {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.collection-panel,
.status-column,
.week-column,
.setup-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.panel-heading-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-heading h2,
.setup-main h2,
.setup-side h2,
.ending-layout h2 {
  margin: 0;
}

.scroll-panel {
  min-height: 0;
  overflow: auto;
}

.ending-collection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  max-height: 430px;
  padding-right: 4px;
}

.ending-card {
  min-width: 0;
  min-height: 92px;
  padding: 10px;
  overflow-wrap: anywhere;
}

.ending-card.locked {
  background:
    repeating-linear-gradient(-45deg, rgba(216, 190, 161, 0.14) 0 6px, transparent 6px 12px),
    rgba(255, 255, 255, 0.62);
  color: var(--muted);
}

.ending-card span,
.ending-card strong,
.ending-card small {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ending-card span {
  font-size: 24px;
}

.ending-card small {
  line-height: 1.35;
  margin-top: 6px;
  color: var(--muted);
}

.ending-card.locked strong {
  color: var(--muted);
  font-weight: 700;
}

.panel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

#collectionHint {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.panel-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.program-grid,
.role-grid,
.profile-grid,
.final-stats,
.achievements {
  display: grid;
  gap: 10px;
}

.program-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 20px;
}

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

.setup-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.setup-step-dot {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(255, 253, 245, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  box-shadow: 2px 2px 0 rgba(47, 41, 33, 0.08);
}

.setup-step-dot.active,
.setup-step-dot.done {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--tape-blue);
}

.setup-step[hidden] {
  display: none !important;
}

.setup-nav {
  justify-content: flex-end;
  margin-top: 16px;
}

.program-card,
.role-card {
  min-height: 168px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.program-card.selected,
.role-card.selected {
  border-color: var(--blue);
  background:
    linear-gradient(135deg, rgba(216, 236, 242, 0.64), rgba(255, 253, 245, 0.88)),
    var(--surface-strong);
  box-shadow: inset 0 0 0 2px rgba(61, 111, 143, 0.22), 4px 4px 0 rgba(47, 41, 33, 0.1);
}

.random-role-card {
  border-style: dashed;
  background:
    linear-gradient(135deg, rgba(255, 245, 196, 0.52), rgba(229, 240, 219, 0.54)),
    var(--surface-strong);
}

.program-card h3,
.role-card h3,
.choice strong {
  margin: 0 0 6px;
}

.program-card p,
.role-card p,
.choice p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.role-preview {
  min-height: 120px;
  line-height: 1.65;
}

.setup-profile-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.82fr);
  gap: 14px;
  margin-top: 12px;
}

.setup-profile-panel .role-preview,
.setup-profile-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(61, 111, 143, 0.07) 1px, transparent 1px) 0 13px / 100% 28px,
    var(--surface-strong);
  padding: 14px;
}

.setup-profile-form {
  display: grid;
  gap: 14px;
}

.name-field {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.name-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fffdf7;
  box-shadow: inset 2px 2px 0 rgba(216, 190, 161, 0.18);
}

.profile-layout {
  display: grid;
  gap: 16px;
}

.profile-hero {
  gap: 14px;
}

.profile-avatar-large,
.avatar,
.ending-badge {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.62), transparent 34%),
    var(--tape-pink);
  box-shadow: 3px 3px 0 rgba(47, 41, 33, 0.1);
}

.profile-avatar-large,
.avatar {
  overflow: hidden;
  padding: 0;
}

.profile-avatar-large img,
.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-large,
.ending-badge {
  width: 72px;
  height: 72px;
  font-size: 36px;
}

.final-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.profile-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.profile-item,
.stat-card {
  padding: 12px;
}

.profile-item small,
.stat-card small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.profile-story,
.ending-afterword {
  border: 1px solid rgba(187, 143, 104, 0.42);
  border-left: 6px solid var(--yellow);
  border-radius: var(--radius);
  padding: 12px 14px;
  background:
    linear-gradient(90deg, rgba(217, 155, 49, 0.16), transparent 34%),
    rgba(255, 253, 245, 0.82);
  line-height: 1.7;
}

.leaderboard-submit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background:
    linear-gradient(90deg, rgba(216, 236, 242, 0.44), transparent 50%),
    var(--surface-strong);
  box-shadow: 3px 3px 0 rgba(47, 41, 33, 0.09);
}

.leaderboard-submit-card strong {
  display: block;
  line-height: 1.5;
}

.collection-modal,
.leaderboard-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px))
    calc(18px + env(safe-area-inset-right, 0px))
    calc(18px + env(safe-area-inset-bottom, 0px))
    calc(18px + env(safe-area-inset-left, 0px));
  background:
    radial-gradient(circle at 20% 18%, rgba(245, 216, 208, 0.22), transparent 28%),
    rgba(47, 41, 33, 0.52);
}

.collection-modal[hidden],
.leaderboard-modal[hidden],
.poster-modal[hidden] {
  display: none;
}

.collection-modal .collection-panel {
  width: min(720px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
}

.leaderboard-panel {
  width: min(560px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background:
    linear-gradient(rgba(61, 111, 143, 0.08) 1px, transparent 1px) 0 13px / 100% 30px,
    var(--surface);
  box-shadow: var(--shadow);
}

.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px))
    calc(18px + env(safe-area-inset-right, 0px))
    calc(18px + env(safe-area-inset-bottom, 0px))
    calc(18px + env(safe-area-inset-left, 0px));
  background:
    radial-gradient(circle at 78% 16%, rgba(216, 236, 242, 0.2), transparent 30%),
    rgba(47, 41, 33, 0.56);
}

.poster-panel {
  width: min(420px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(216, 190, 161, 0.13) 1px, transparent 1px) 24px 0 / 30px 100%,
    var(--surface);
  box-shadow: var(--shadow);
}

.poster-preview {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(61, 111, 143, 0.08) 1px, transparent 1px) 0 12px / 100% 28px,
    #efe3d2;
}

.poster-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.poster-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.leaderboard-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.leaderboard-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 245, 0.82);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  box-shadow: 2px 2px 0 rgba(47, 41, 33, 0.08);
}

.leaderboard-tab.active {
  border-color: var(--blue);
  background: var(--tape-blue);
  color: var(--blue);
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
}

.leaderboard-row,
.leaderboard-empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(245, 216, 208, 0.22), transparent 40%),
    var(--surface-strong);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.leaderboard-empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.leaderboard-rank {
  font-weight: 900;
  color: var(--blue);
}

.leaderboard-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-name strong,
.leaderboard-name small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-name small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.leaderboard-score {
  font-weight: 900;
  color: var(--green);
  text-align: right;
}

.status-column,
.week-column {
  max-height: calc(100dvh - 104px);
}

.status-column,
.week-column {
  overflow: auto;
}

.player-card {
  gap: 10px;
}

.avatar {
  width: 54px;
  height: 54px;
  font-size: 28px;
}

#statsPanel {
  display: grid;
  gap: 8px;
}

.stat-card {
  display: grid;
  gap: 6px;
}

.stat-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, rgba(120, 109, 95, 0.18) 0 2px, transparent 2px 8px),
    #eadcca;
}

.stat-bar span {
  display: block;
  height: 100%;
  background:
    linear-gradient(rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0)),
    var(--green);
}

.stat-card.warn .stat-bar span {
  background: var(--yellow);
}

.stat-card.danger .stat-bar span {
  background: var(--red);
}

.pressure-card,
.phase-banner,
.result,
.event-panel,
.action-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(61, 111, 143, 0.07) 1px, transparent 1px) 0 15px / 100% 31px,
    var(--surface-strong);
  padding: 14px;
  box-shadow: 3px 3px 0 rgba(47, 41, 33, 0.08);
}

.todo-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 170px;
}

.log-item {
  border-left: 4px solid var(--green);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 10px;
  background: rgba(220, 235, 210, 0.54);
  line-height: 1.55;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20px, 1fr));
  gap: 4px;
}

.week-dot {
  min-height: 8px;
  border-radius: 999px;
  background: #ded2c2;
  box-shadow: inset 0 0 0 1px rgba(99, 74, 42, 0.12);
}

.week-dot.past {
  background: var(--green);
}

.week-dot.current {
  background: var(--yellow);
}

.choices,
.delta-list,
.achievements {
  display: grid;
  gap: 8px;
}

.choice {
  padding: 12px;
  text-align: left;
  min-width: 0;
}

.choice {
  cursor: pointer;
}

.choice.selected {
  border-color: var(--blue);
  background:
    linear-gradient(90deg, rgba(216, 236, 242, 0.7), rgba(255, 253, 245, 0.8)),
    var(--surface-strong);
  box-shadow: inset 0 0 0 1px rgba(61, 111, 143, 0.18), 4px 4px 0 rgba(47, 41, 33, 0.09);
}

.choice:disabled {
  pointer-events: none;
}

.choice-badge {
  display: inline-flex;
  margin-top: 8px;
  border-radius: var(--radius);
  background: var(--blue);
  padding: 4px 7px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.event-tag {
  display: inline-flex;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--tape-green);
  padding: 6px 9px;
  color: var(--blue);
  font-weight: 800;
  box-shadow: 2px 2px 0 rgba(47, 41, 33, 0.08);
}

.event-panel h2,
.event-panel p {
  white-space: pre-line;
}

.event-panel p,
.result p,
.choice p,
.passive-item p,
.ending-afterword {
  overflow-wrap: anywhere;
}

#eventText {
  max-height: min(32dvh, 260px);
  overflow: auto;
  padding-right: 4px;
}

.choices {
  max-height: min(36dvh, 320px);
  overflow: auto;
  padding-right: 2px;
}

#resultText {
  max-height: min(28dvh, 220px);
  overflow: auto;
  padding-right: 4px;
}

.passive-item {
  padding: 10px;
  background:
    linear-gradient(90deg, rgba(245, 216, 208, 0.34), transparent 48%),
    rgba(255, 253, 245, 0.76);
}

.delta-list {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.delta-pill {
  padding: 8px 10px;
  font-weight: 800;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0)),
    var(--tape-yellow);
}

.delta-pill.plus {
  color: var(--green);
}

.delta-pill.minus {
  color: var(--red);
}

.ending-layout {
  max-width: 880px;
  margin: 0 auto;
  text-align: center;
}

.ending-layout > p {
  line-height: 1.75;
}

.ending-badge {
  margin: 0 auto 10px;
}

.achievements {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.achievement {
  padding: 10px;
}

.about-game {
  margin-top: 16px;
  padding: 14px 16px;
  box-shadow: none;
  line-height: 1.7;
}

.about-game summary {
  cursor: pointer;
  font-weight: 800;
}

.week-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px))
    calc(18px + env(safe-area-inset-right, 0px))
    calc(18px + env(safe-area-inset-bottom, 0px))
    calc(18px + env(safe-area-inset-left, 0px));
  background:
    radial-gradient(circle at 22% 22%, rgba(245, 216, 208, 0.18), transparent 26%),
    rgba(47, 41, 33, 0.58);
}

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

.week-modal-card {
  width: min(680px, 100%);
  max-height: min(680px, calc(100dvh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(61, 111, 143, 0.08) 1px, transparent 1px) 0 15px / 100% 31px,
    var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-head h2 {
  margin: 8px 0;
}

.week-modal-list {
  max-height: min(44dvh, 360px);
  overflow: auto;
}

.toast {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  max-width: min(340px, calc(100vw - 36px));
  transform: translateY(18px);
  opacity: 0;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 253, 245, 0.28);
  background: #3a3026;
  color: #fff;
  padding: 11px 14px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

[hidden] {
  display: none !important;
}

@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 4px 5px 0 rgba(47, 41, 33, 0.14);
  }

  .choice:not(:disabled):hover {
    border-color: var(--blue);
    background:
      linear-gradient(90deg, rgba(216, 236, 242, 0.34), transparent 46%),
      var(--surface-strong);
  }
}

@media (pointer: coarse) {
  .btn,
  .choice,
  .mode-option {
    min-height: 44px;
  }
}

@media (max-width: 920px) {
  .home-layout,
  .setup-layout,
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .status-column,
  .week-column {
    max-height: none;
  }

  .status-column {
    position: sticky;
    top: 0;
    z-index: 6;
    gap: 10px;
    max-height: min(44dvh, 360px);
    overflow: auto;
    box-shadow: 0 10px 24px rgba(36, 33, 29, 0.12);
  }

  .status-secondary {
    display: none;
  }

  .player-card {
    align-items: center;
  }

  #statsPanel {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  #statsPanel .stat-card {
    gap: 4px;
    padding: 8px;
  }

  #statsPanel .stat-card small {
    margin-bottom: 0;
    font-size: 11px;
  }

  #statsPanel .stat-card strong {
    font-size: 14px;
  }

  .pressure-card {
    padding: 10px;
    font-size: 13px;
  }

  .home-copy h1 {
    font-size: 34px;
  }

  .program-grid,
  .role-grid,
  .setup-profile-panel,
  .final-stats,
  .action-grid {
    grid-template-columns: 1fr;
  }

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

  .panel-footer,
  .leaderboard-submit-card {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    justify-content: flex-start;
  }

  .leaderboard-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .leaderboard-score {
    grid-column: 2;
    text-align: left;
  }

  .leaderboard-tabs {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .home-copy,
  .collection-panel,
  .setup-main,
  .setup-side,
  .profile-layout,
  .status-column,
  .week-column,
  .ending-layout {
    padding: 16px;
  }

  .setup-progress {
    margin-bottom: 14px;
  }

  .program-card,
  .role-card {
    min-height: 0;
  }

  .home-copy h1 {
    font-size: 29px;
  }

  .game-layout {
    gap: 10px;
  }

  .status-column,
  .week-column {
    padding: 12px;
  }

  .avatar {
    width: 42px;
    height: 42px;
    font-size: 23px;
  }

  .player-card h2 {
    margin: 0 0 2px;
    font-size: 18px;
  }

  .player-card p {
    margin: 0;
    font-size: 13px;
  }

  #statsPanel {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #statsPanel .stat-card {
    padding: 7px 5px;
  }

  #statsPanel .stat-card small {
    font-size: 10px;
    line-height: 1.25;
  }

  #statsPanel .stat-card strong {
    font-size: 12px;
  }

  .stat-bar {
    height: 6px;
  }

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

  .ending-collection-grid {
    grid-template-columns: 1fr;
    max-height: 360px;
  }
}
