:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #f7efdf;
  color: #000;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-width: 320px;
  background: #f7efdf;
  color: #000;
}

.filing-link {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  padding: 2px 5px;
  background: #f7efdf;
  color: #000;
  font-size: 11px;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

button {
  border: 2px solid #000;
  border-radius: 6px;
  background: #fff8ea;
  color: #000;
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

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

#app {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
  margin-bottom: 8px;
}

.main-menu {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 14px;
}

.menu-panel {
  width: min(100%, 420px);
  text-align: center;
}

.game-title {
  margin-bottom: 28px;
  font-size: 44px;
  font-weight: 900;
}

.menu-options,
.menu-modal-options {
  display: grid;
  gap: 12px;
}

.menu-option,
.menu-modal-options button {
  width: 100%;
  min-height: 58px;
  border-radius: 12px;
  font-size: 18px;
}

.setting-row {
  display: grid;
  gap: 10px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #f7efdf;
  padding: 10px;
  font-weight: 900;
}

.speed-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.speed-options button.selected {
  box-shadow: inset 0 0 0 2px #000;
  background: #f7efdf;
}

.tutorial-card {
  min-height: 330px;
  border: 2px solid #000;
  border-radius: 12px;
  background: #fff8ea;
  padding: 14px;
  margin-top: 10px;
  text-align: left;
}

.tutorial-visual {
  height: 150px;
  margin-bottom: 14px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #f7efdf;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.tutorial-hand,
.tutorial-dice,
.tutorial-bet-row,
.tutorial-pot,
.tutorial-versus,
.tutorial-victory {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-hand { gap: 6px; }

.tutorial-playing-card {
  width: 46px;
  height: 66px;
  border: 2px solid #000;
  border-radius: 6px;
  background: #fff8ea;
  display: grid;
  grid-template-rows: 1fr 1fr;
  place-items: center;
  font-style: normal;
}

.tutorial-playing-card b { align-self: end; font-size: 26px; }
.tutorial-playing-card em { align-self: start; font-size: 18px; font-style: normal; font-weight: 900; }
.tutorial-plus, .tutorial-arrow { font-size: 26px; font-weight: 900; }

.tutorial-skill-card {
  width: 76px;
  height: 72px;
  border: 3px solid #000;
  border-radius: 7px;
  background: #fff8ea;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.tutorial-skill-card small { font-size: 14px; }
.tutorial-skill-ready { border-color: #6f2a76; }

.tutorial-pollen {
  padding: 8px;
  border: 2px solid #000;
  border-radius: 7px;
  background: #fff8ea;
  font-weight: 900;
  white-space: nowrap;
}

.tutorial-crown { font-size: 46px; line-height: 1; }

.tutorial-bet-row {
  width: min(94%, 360px);
  gap: 4px;
}

.tutorial-bet-row span {
  flex: 1;
  padding: 8px 2px;
  border: 2px solid #000;
  border-radius: 6px;
  background: #fff8ea;
  text-align: center;
  font-weight: 900;
}

.tutorial-pot {
  position: absolute;
  margin-top: 88px;
  gap: 3px;
}

.tutorial-pot i {
  width: 12px;
  height: 12px;
  border: 2px solid #000;
  border-radius: 50%;
  background: #fff8ea;
}

.tutorial-pot b { margin-left: 6px; font-size: 13px; }
.tutorial-dice { gap: 6px; }

.tutorial-dice span {
  width: 42px;
  height: 42px;
  border: 2px solid #000;
  border-radius: 7px;
  background: #fff8ea;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900;
}

.tutorial-versus { gap: 8px; flex-wrap: wrap; text-align: center; }
.tutorial-versus span { display: grid; gap: 4px; padding: 9px; border: 2px solid #000; border-radius: 7px; background: #fff8ea; }
.tutorial-versus small { font-size: 12px; }
.tutorial-versus i { font-size: 24px; font-style: normal; font-weight: 900; }
.tutorial-versus strong { flex-basis: 100%; font-size: 16px; }
.tutorial-victory { gap: 10px; flex-wrap: wrap; text-align: center; }
.tutorial-victory b, .tutorial-victory strong { padding: 8px; border: 2px solid #000; border-radius: 7px; background: #fff8ea; }

.tutorial-card > strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.2;
}

.tutorial-card > p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
}

.tutorial-progress {
  margin: 12px 0 8px;
  text-align: center;
  font-size: 14px;
}

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

.tutorial-actions button:last-child {
  grid-column: 1 / -1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.topbar p,
.hint {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

.status-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #fff8ea;
  padding: 8px;
  font-size: 13px;
}

.status-strip span {
  min-width: 0;
}

.status-new-game {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: stretch;
  min-width: 76px;
  padding: 6px 8px;
  font-size: 12px;
}

.table {
  margin-top: 8px;
}

.table-ring {
  position: relative;
  min-height: 262px;
  border: 3px solid #000;
  border-radius: 14px;
  background: #fff8ea;
  overflow: hidden;
  padding: 10px;
}

.table-center {
  position: absolute;
  left: 50%;
  top: 61%;
  width: min(48%, 250px);
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 1;
}

.table-title {
  margin-bottom: 5px;
  font-weight: 800;
  font-size: 12px;
}

.table-bet-total {
  display: inline-block;
  border: 2px solid #000;
  border-radius: 6px;
  background: #f7efdf;
  padding: 4px 6px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
}

.table-hand-delta {
  min-height: 18px;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 900;
}

.table-players {
  position: absolute;
  inset: 10px;
  z-index: 2;
}

.player-seat {
  position: absolute;
  width: 19%;
  min-height: 66px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #f7efdf;
  color: #000;
  padding: 4px;
  text-align: left;
  overflow: visible;
}

.player-seat:nth-child(1) {
  left: 6%;
  top: 0;
  transform: none;
}

.player-seat:nth-child(2) {
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.player-seat:nth-child(3) {
  right: 6%;
  top: 0;
}

.player-seat:nth-child(4) {
  left: 0;
  bottom: 0;
}

.player-seat:nth-child(5) {
  right: 0;
  bottom: 0;
}

.player-seat.dealer {
  outline: 2px solid #000;
  outline-offset: 3px;
}

.player-seat.acting {
  box-shadow: 0 0 0 3px #000;
}

.player-seat.folded {
  text-decoration: line-through;
}

.player-seat.targetable {
  outline: 3px solid #000;
  outline-offset: 4px;
}

.seat-name {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 4px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  min-height: 14px;
}

.seat-name span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-stat {
  position: relative;
  z-index: 2;
  margin-top: 16px;
  max-width: 100%;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.2;
  white-space: normal;
}

.seat-stat div {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.seat-bet {
  border: 2px solid #000;
  border-radius: 5px;
  margin: 3px 0;
  padding: 2px 3px;
  background: #fff8ea;
  font-weight: 900;
}

.seat-notice {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  z-index: 5;
  min-width: 56px;
  max-width: 116px;
  border: 2px solid #000;
  border-radius: 6px;
  background: #fff8ea;
  color: #000;
  padding: 3px 5px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
  white-space: normal;
}

.player-seat:nth-child(4) .seat-notice,
.player-seat:nth-child(5) .seat-notice {
  top: auto;
  bottom: calc(100% + 4px);
}

.player-seat:nth-child(2) .seat-notice {
  left: calc(100% + 6px);
  top: 50%;
  bottom: auto;
  max-width: 72px;
  transform: translateY(-50%);
}

.cards {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 62px;
}

.card {
  width: 42px;
  height: 58px;
  border: 2px solid #000;
  border-radius: 6px;
  background: #fff8ea;
  color: #000;
  display: grid;
  grid-template-rows: 1fr 1fr;
  place-items: center;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
}

.card.red {
  color: #000;
}

.card-rank {
  align-self: start;
  font-size: 16px;
  line-height: 1;
}

.card-suit-icon {
  --suit-size: 24px;
  align-self: end;
  width: var(--suit-size);
  height: var(--suit-size);
  display: grid;
  place-items: center;
}

.card-suit-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.card-suit-icon.spade img,
.card-suit-icon.club img {
  transform: translateX(-4%);
}

.card.back {
  color: transparent;
  background: #fff8ea;
}

.community-cards .card.flip-in {
  animation: cardFlipReveal 520ms ease both;
}

.foresee-cards {
  justify-content: center;
  margin-top: 10px;
}

.mini-cards {
  position: absolute;
  z-index: 1;
  left: 4px;
  right: 4px;
  top: 28px;
  bottom: 4px;
  justify-content: center;
  align-items: end;
  gap: 3px;
  flex-wrap: nowrap;
  min-height: 0;
  margin-top: 0;
  opacity: 0.42;
  pointer-events: none;
}

.mini-cards .card {
  width: clamp(18px, 6vw, 27px);
  height: clamp(26px, 8.6vw, 38px);
  border-style: solid;
  border-radius: 4px;
  font-size: 9px;
  background: #f7efdf;
}

.mini-cards .card-suit-icon {
  --suit-size: clamp(11px, 3.6vw, 16px);
}

.mini-cards .card-rank {
  font-size: clamp(9px, 2.8vw, 12px);
}

.mini-cards .card.back {
  background: #f7efdf;
}

.player-seat.showdown .seat-stat {
  animation: seatTextFade 680ms ease forwards;
}

.seat-card-placeholder {
  opacity: 0.28;
  background: #f7efdf;
}

.seat-card-placeholder::after {
  content: "";
}

.player-seat.showdown .mini-cards {
  opacity: 1;
}

.player-seat.showdown .mini-cards .card {
  border-style: solid;
  animation: cardFlipReveal 680ms ease both;
  transform-origin: center;
}

.player-seat.showdown .mini-cards .card:nth-child(2) {
  animation-delay: 110ms;
}

@keyframes seatTextFade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes cardFlipReveal {
  0% {
    transform: rotateY(90deg) scale(0.92);
    opacity: 0.2;
  }
  50% {
    transform: rotateY(0deg) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
  }
}

.hero-area {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  border: 3px solid #000;
  border-radius: 8px;
  background: #f7efdf;
  padding: 8px;
  display: grid;
  gap: 7px;
}

.hero-top {
  display: grid;
  grid-template-columns: minmax(118px, 42%) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.hero-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  font-size: 11px;
  line-height: 1.2;
}

.hero-summary span {
  border: 2px solid #000;
  border-radius: 5px;
  background: #fff8ea;
  padding: 4px 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-cards {
  justify-content: flex-start;
  align-content: end;
  align-items: end;
  flex-wrap: nowrap;
  min-height: 96px;
}

.hero-cards .card,
.hero-card-placeholder {
  width: 58px;
  height: 84px;
  font-size: 15px;
}

.hero-cards .card-suit-icon {
  --suit-size: 36px;
}

.hero-cards .card-rank {
  font-size: 22px;
}

.hero-hand-box {
  display: grid;
  gap: 3px;
  align-content: start;
}

.hero-hand-title {
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.hero-card-placeholder {
  border: 2px dashed #000;
  border-radius: 6px;
  background: #fff8ea;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.actions button {
  min-height: 48px;
  padding: 8px 4px;
  font-size: 14px;
}

.lower-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-bottom: 14px;
}

.panel {
  border: 2px solid #000;
  border-radius: 8px;
  background: #fff8ea;
  padding: 10px;
}

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

.skill-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.skill-pill {
  min-height: 34px;
  border: 2px solid #000;
  border-radius: 5px;
  background: #fff8ea;
  color: #000;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 7px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-pill.red {
  border-color: #b00000;
}

.skill-pill.blue {
  border-color: #0040b0;
}

.skill-pill.purple {
  border-color: #6a00a8;
}

.skill-pill.ready {
  outline: 2px solid #000;
  outline-offset: 1px;
  opacity: 1;
}

.skill-pill.disabled {
  opacity: 0.6;
}

.skill {
  min-height: 98px;
  border: 2px solid #000;
  border-radius: 7px;
  background: #fff8ea;
  padding: 8px;
  font-size: 12px;
  line-height: 1.35;
}

button.skill {
  width: 100%;
  color: #000;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.skill:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.skill.ready {
  outline: 2px solid #000;
  outline-offset: 2px;
}

.skill.used {
  text-decoration: line-through;
}

.auto-skill-button {
  display: none;
}

.skill.red {
  border-color: #b00000;
}

.skill.blue {
  border-color: #0040b0;
}

.skill.purple {
  border-color: #6a00a8;
}

.skill.none {
  border-color: #000;
}

.skill strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.skill small {
  color: #000;
}

.log-panel {
  max-height: 170px;
  overflow: auto;
}

.log-summary {
  min-height: 30px;
  border: 2px solid #000;
  border-radius: 5px;
  background: #fff8ea;
  color: #000;
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  margin-top: 8px;
}

.modal-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.result-card {
  text-align: center;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.result-emblem {
  width: 88px;
  height: 88px;
  border: 3px double #000;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 6px auto 12px;
  background: #fff8ea;
  color: #000;
  font-size: 20px;
  font-weight: 900;
}

.result-title {
  font-size: 20px;
  font-weight: 900;
  margin: 8px 0;
}

.result-note {
  border: 2px solid #000;
  border-radius: 6px;
  padding: 8px;
  background: #f7efdf;
  font-weight: 900;
}

.result-card .modal-actions {
  grid-template-columns: 1fr;
}

#log {
  margin: 0;
  padding-left: 20px;
  color: #000;
  line-height: 1.45;
  font-size: 12px;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
}

.modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  bottom: auto;
  width: min(92vw, 460px);
  max-height: 82vh;
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 3px solid #000;
  border-radius: 10px;
  background: #fff8ea;
  padding: 12px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.detail-grid span,
.quest-line {
  border: 2px solid #000;
  border-radius: 6px;
  padding: 7px;
  background: #f7efdf;
}

.modal-card .skill-grid {
  grid-template-columns: 1fr;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

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

.raise-choice {
  min-height: 46px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #fff8ea;
  color: #000;
  padding: 6px 4px;
  text-align: center;
}

.raise-choice strong {
  display: block;
  font-size: 18px;
  line-height: 1;
}

.raise-choice small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
}

.choice-card {
  border: 2px solid #000;
  border-radius: 8px;
  background: #fff8ea;
  color: #000;
  padding: 10px;
  text-align: left;
}

.choice-card strong {
  display: block;
  margin-bottom: 4px;
}

.choice-card small {
  display: block;
  margin-bottom: 6px;
}

.quest-card-line {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #000;
  display: grid;
  gap: 3px;
  font-size: 12px;
  line-height: 1.35;
}

.choice-card.red {
  border-color: #b00000;
}

.choice-card.blue {
  border-color: #0040b0;
}

.choice-card.purple {
  border-color: #6a00a8;
}

.discard-board {
  border: 2px solid #000;
  border-radius: 8px;
  background: #f7efdf;
  padding: 8px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  line-height: 1.35;
}

.discard-board strong {
  font-size: 12px;
}

@media (max-width: 380px) {
  .table-ring {
    min-height: 248px;
    padding: 8px;
  }

  .player-seat {
    width: 21%;
    min-height: 64px;
    padding: 3px;
  }

  .seat-name {
    left: 3px;
    right: 3px;
    top: 3px;
    font-size: 9px;
  }

  .seat-stat {
    margin-top: 15px;
    font-size: 8px;
    line-height: 1.25;
  }

  .mini-cards .card {
    width: 18px;
    height: 26px;
  }
}

@media (min-width: 720px) {
  #app {
    padding: 16px;
  }

  .status-strip {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }

  .table-ring {
    min-height: 300px;
  }

  .player-seat {
    width: 18%;
    min-height: 76px;
  }

  .lower-grid {
    grid-template-columns: 1.3fr 1fr;
  }

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

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