:root {
  --paper: #f4e3c3;
  --paper-deep: #dfc79e;
  --ink: #241a14;
  --muted: #745f4c;
  --line: #c7a677;
  --lacquer: #271a13;
  --cinnabar: #a73427;
  --cinnabar-dark: #76261d;
  --gold: #d6b475;
  --jade: #53665c;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #d7c09d;
}

body {
  position: relative;
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  background: #d7c09d url("./assets/BG.png") center / cover no-repeat fixed;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 44px 1fr 86px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 0 max(10px, env(safe-area-inset-left)) 0 max(10px, env(safe-area-inset-right));
  color: #f1dfbd;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 36%, rgba(214, 174, 112, 0.08)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 2px, transparent 2px 9px),
    var(--lacquer);
  border-bottom: 2px solid #513621;
  box-shadow: 0 8px 20px rgba(22, 12, 8, 0.3);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

.draw-stat {
  color: rgba(232, 209, 165, 0.9);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  min-width: 34px;
  text-align: right;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  line-height: 1;
}

.brand-main,
.brand-accent {
  overflow: hidden;
  white-space: nowrap;
}

.brand-main {
  font-size: 17px;
  font-weight: 700;
}

.brand-divider {
  display: block;
  flex: 0 0 1px;
  width: 1px;
  height: 18px;
  background: rgba(215, 180, 113, 0.55);
}

.brand-accent {
  color: #d55342;
  font-size: 16px;
  font-weight: 700;
}

.restart-btn,
.answer-btn,
.primary-action,
.secondary-action {
  border: 1px solid rgba(236, 205, 148, 0.72);
  border-radius: 5px;
  color: #f7e7c4;
  background: linear-gradient(180deg, #b94332, #84261d);
  box-shadow: inset 0 0 0 2px rgba(255, 241, 201, 0.12), 0 8px 18px rgba(52, 21, 14, 0.22);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.restart-btn:hover,
.answer-btn:hover,
.primary-action:hover,
.secondary-action:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

.restart-btn {
  flex: 0 0 auto;
  min-width: 66px;
  height: 26px;
  padding: 0 7px;
  color: #e8d1a5;
  background: rgba(255, 246, 218, 0.06);
  border-color: rgba(226, 205, 165, 0.42);
  box-shadow: none;
  font-size: 11px;
}

.stage {
  display: grid;
  place-items: center;
  padding: 14px 9px 12px;
}

.card-wrap {
  width: 357px;
  max-width: calc(100vw - 18px);
}

.poem-card {
  position: relative;
  width: 100%;
  min-height: 536px;
  padding: 36px 38px 34px;
  overflow: hidden;
  background: url("./assets/concept-play-card-bg.png") center / 100% 100% no-repeat;
  border: 0;
  border-radius: 17px;
  outline: 0;
  box-shadow: 0 6px 14px rgba(19, 12, 8, 0.18);
}

.poem-card::before,
.poem-card::after,
.poem-card > .corner {
  display: none;
}

.cover-view {
  position: relative;
  display: block;
}

.cover-card-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 17px;
  box-shadow: none;
}

.cover-brand-vertical {
  position: absolute;
  top: 52px;
  right: 48px;
  color: rgba(117, 38, 29, 0.76);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
  writing-mode: vertical-rl;
}

.poem-card[data-state="cover"] {
  min-height: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 17px;
  outline: 0;
  box-shadow: none;
}

.poem-card[data-state="cover"]::before,
.poem-card[data-state="cover"]::after,
.poem-card[data-state="cover"] > .corner {
  display: none;
}

.card-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 96px;
}

.serial-ribbon {
  width: 56px;
  min-height: 88px;
  padding: 12px 0 10px;
  text-align: center;
  color: #f9e4bf;
  background: url("./assets/concept-ribbon-bg.png") center / 100% 100% no-repeat;
  box-shadow: none;
}

.serial-ribbon span {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.serial-ribbon strong {
  display: block;
  font-size: 25px;
}

.field {
  position: relative;
  margin: 0 0 20px;
  text-align: center;
}

.field-label {
  display: inline-grid;
  grid-template-columns: 70px auto 70px;
  align-items: center;
  gap: 12px;
  color: var(--cinnabar);
  font-size: 16px;
  font-weight: 700;
}

.field-label::before,
.field-label::after {
  content: "";
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line));
}

.field-label::after {
  background: linear-gradient(90deg, var(--line), transparent);
}

.poem-line {
  margin: 19px 0 0;
  color: #1f1712;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.55;
}

.answer-line {
  font-size: 23px;
}

.special-field p {
  max-width: 260px;
  min-height: 42px;
  margin: 15px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.meta-list {
  display: grid;
  gap: 10px;
  max-width: 270px;
  margin: 8px auto 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(163, 116, 65, 0.32);
}

.meta-list dt {
  color: var(--cinnabar);
  font-size: 15px;
  font-weight: 700;
}

.meta-list dd {
  margin: 0;
  color: #3f3126;
  font-size: 16px;
  line-height: 1.55;
}

.answer-btn {
  display: block;
  min-width: 156px;
  height: 48px;
  margin: 26px auto 0;
  font-size: 22px;
  font-weight: 700;
}

.action-dock {
  display: grid;
  place-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: url("./assets/concept-dock-bg.png") center / cover no-repeat;
  border-top: 0;
}

.primary-action {
  min-width: 176px;
  height: 54px;
  font-size: 26px;
  font-weight: 700;
}

.primary-action.ghost {
  color: #e1cfab;
  background: linear-gradient(180deg, rgba(92, 79, 62, 0.82), rgba(48, 39, 31, 0.88));
  border-color: rgba(226, 205, 165, 0.45);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(21, 14, 10, 0.58);
}

.modal {
  width: min(332px, calc(100vw - 32px));
  padding: 30px 28px 28px;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 6px solid #8e3427;
  border-radius: 12px;
  outline: 1px solid rgba(213, 180, 113, 0.78);
  outline-offset: -14px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.42);
}

.modal h2 {
  margin: 0 0 14px;
  color: var(--cinnabar-dark);
  font-size: 25px;
}

.modal p {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 18px;
}

.modal-action {
  min-width: 136px;
  height: 50px;
  font-size: 22px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.modal-actions .modal-action {
  min-width: 112px;
  height: 46px;
  font-size: 20px;
}

.secondary-action {
  color: #6d4f32;
  background: rgba(255, 249, 235, 0.45);
  border-color: rgba(141, 77, 39, 0.46);
  box-shadow: none;
}

[hidden] {
  display: none !important;
}

.poem-card[data-card-type="special"] #upper-label {
  display: none !important;
}

@media (min-width: 768px) {
  .app-shell {
    grid-template-rows: 44px 1fr 104px;
  }

  .topbar {
    padding-right: 16px;
    padding-left: 16px;
  }

  .brand {
    gap: 8px;
  }

  .restart-btn {
    min-width: 72px;
    height: 28px;
    font-size: 12px;
  }

  .stage {
    padding-top: 28px;
    padding-bottom: 20px;
  }
}

@media (max-width: 360px) {
  .brand-accent,
  .brand-divider {
    display: none;
  }

  .card-wrap {
    width: calc(100vw - 18px);
  }

  .poem-card {
    padding-right: 35px;
    padding-left: 35px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .poem-card.is-entering {
    animation: cardIn 280ms ease-out;
  }

  .answer-block.is-revealed {
    animation: answerIn 220ms ease-out;
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes answerIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
