:root {
  font-family:
    "Noto Sans KR",
    -apple-system,
    sans-serif;
  color: #20382e;
  background: #e9e8e1;
  font-synthesis: none;
  --paper: #f6f4ed;
  --green: #245640;
  --muted: #788078;
  --line: #e5e6df;
  --red: #c84c37;
}

/* Full-height home artwork; scorekeeping remains on its readable plain surface. */
.app-shell:has(#landingView:not(.hidden)) {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.app-shell:has(#landingView:not(.hidden))::before {
  content: '';
  position: absolute;
  inset: -6px;
  z-index: -1;
  pointer-events: none;
  background-image: url('../../../assets/hwatu-mobile-background.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(2px);
}
#landingView { display: flex; flex-direction: column; flex: 1; }
.home-actions { margin-top: auto; padding-top: 24px; }
.home-actions .home-defaults { color: #20382e; background: #fffaf0eb; border-radius: 8px; padding: 8px; }
.app-shell:has(#landingView:not(.hidden)) #resumeGameBtn {
  background: #fffaf0eb;
  border-radius: 10px;
  padding-left: 12px;
  padding-right: 12px;
}
@media (max-width: 599px) {
  .app-shell:has(#landingView:not(.hidden)) {
    max-width: none;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}
button,
summary {
  cursor: pointer;
}
button {
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
:focus-visible {
  outline: 3px solid #bb943e;
  outline-offset: 3px;
}
.hidden {
  display: none !important;
}
.app-shell {
  width: 100%;
  max-width: 480px;
  margin: auto;
  min-height: 100dvh;
  background: var(--paper);
  padding: calc(22px + env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 34px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.7px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.brand span {
  display: grid;
  place-items: center;
  width: 25px;
  height: 31px;
  border-radius: 5px;
  background: var(--red);
  color: #fff4de;
  font-family: serif;
  font-size: 17px;
  transform: rotate(-7deg);
  margin-right: 3px;
}
.brand em {
  font-style: normal;
  font-weight: 500;
  color: #7a8177;
  font-size: 13px;
}
.status-pill {
  font-size: 10px;
  color: #69816c;
  white-space: nowrap;
}
.status-pill::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #789a74;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.hero h1 {
  font-size: clamp(29px, 8vw, 36px);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -1.6px;
  margin: 0;
}
.hero h1 i {
  font-style: normal;
  color: var(--red);
}
.lead {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 23px;
  line-height: 1.6;
}
.home-art {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  background: #e8ddc7;
  aspect-ratio: 1.46;
  isolation: isolate;
}
.home-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 71%;
}
.home-art figcaption {
  position: absolute;
  inset: auto 0 0;
  padding: 22px 17px 14px;
  display: flex;
  justify-content: space-between;
  color: #fff4dd;
  background: linear-gradient(transparent, #193828c9);
  font-size: 11px;
  letter-spacing: 0.3px;
}
.home-defaults {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin: 23px 0 16px;
  color: #707a70;
  font-size: 12px;
}
.home-defaults i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #b7bbae;
}
.primary-button {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 15px 18px;
  border: 0;
  border-radius: 13px;
  background: var(--green);
  color: #fffef6;
  font-size: 15px;
  font-weight: 600;
}
.primary-button:hover {
  background: #1c4834;
}
.primary-button span {
  float: right;
}
.home-help {
  border-top: 1px solid var(--line);
  margin-top: 26px;
  font-size: 12px;
  color: #7a8178;
}
.home-help summary {
  list-style: none;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.home-help summary::-webkit-details-marker {
  display: none;
}
.home-help p {
  line-height: 1.9;
  margin: 0 0 14px;
}
#resumeGameBtn {
  width: 100%;
  margin-top: 9px;
}
dialog {
  border: 0;
  padding: 0;
  color: inherit;
  background: #fffef9;
  width: min(440px, calc(100% - 24px));
  max-height: calc(
    100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
  border-radius: 24px;
  overflow-y: auto;
}
dialog::backdrop {
  background: #15271d88;
  backdrop-filter: blur(5px);
}
.setup-dialog {
  width: 100%;
  max-width: 100%;
  left: 0;
  right: 0;
  border-radius: 20px 20px 0 0;
  --visible-height: 100dvh;
  --visible-top: 0px;
  position: fixed;
  margin: 0 auto;
  top: calc(var(--visible-top) + var(--visible-height));
  bottom: auto;
  transform: translateY(-100%);
  max-height: calc(var(--visible-height) - 24px - env(safe-area-inset-top));
  overflow: hidden;
}
.setup-card {
  padding: 18px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  max-height: calc(var(--visible-height, 100dvh) - 24px - env(safe-area-inset-top));
}
.setup-card::before {
  content: "";
  display: block;
  width: 32px;
  height: 4px;
  border-radius: 8px;
  background: #dedfd6;
  margin: -6px auto 14px;
}
.wizard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.close-button {
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  font-size: 25px;
  color: #7a8178;
}
.wizard-progress {
  height: 3px;
  background: #e8ebe2;
  margin: 10px 0 28px;
  border-radius: 3px;
  overflow: hidden;
}
.wizard-progress i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width 0.2s;
}
.wizard-step {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding: 12px;
  flex: 1 1 auto;
}
.wizard-step > .section-title { margin-top: 2px; }
.wizard-step:not(.hidden) { padding-bottom: 8px; }
.wizard-head, .wizard-progress, .wizard-actions { flex-shrink: 0; }
body:has(.setup-dialog[open]) { overflow: hidden; }
.section-title > span {
  display: none;
}
.section-title h2 {
  font-size: 23px;
  letter-spacing: -0.9px;
  margin: 0 0 8px;
}
.section-title p {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}
.player-inputs {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}
.player-line {
  display: flex;
  gap: 10px;
  align-items: center;
}
.player-number {
  flex-shrink: 0;
  width: 30px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #edf0e5;
  color: #597351;
  font-size: 11px;
}
.player-line:nth-child(2) .player-number {
  background: #f4e9df;
  color: #a27350;
}
.player-line:nth-child(3) .player-number {
  background: #e7ecf2;
  color: #617b92;
}
input,
select {
  min-width: 0;
}
.player-line input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  background: white;
  font-size: 16px;
}
.remove-player {
  border: 0;
  background: transparent;
  min-width: 36px;
  height: 44px;
  color: var(--red);
  font-size: 21px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--green);
  min-height: 44px;
  font-size: 12px;
  font-weight: 600;
}
.wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.outline-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid #dbe0d5;
  background: transparent;
  color: #64765e;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
}
.wizard-actions .outline-button {
  min-width: 70px;
}
.mode-grid {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}
.mode-option {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 7px 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
}
.mode-option.active {
  border-color: var(--green);
  background: #f0f5eb;
  box-shadow: inset 0 0 0 1px var(--green);
}
.mode-option > input {
  position: absolute;
  opacity: 0;
  width: 1px;
}
.mode-icon {
  grid-row: span 2;
  color: #a78c57;
  font-size: 21px;
}
.mode-option strong {
  font-size: 14px;
}
.mode-option small {
  font-size: 11px;
  color: var(--muted);
}
.mode-field {
  grid-column: 2;
  font-size: 12px;
  color: #7a8178;
}
.mode-field input {
  width: 95px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  font-size: 16px;
  margin-right: 7px;
}
.rules-row {
  display: grid;
  gap: 18px;
  margin-top: 26px;
  font-size: 14px;
}
.rules-row > label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.inline-input {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.inline-input input {
  width: 90px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px;
  text-align: right;
  font-size: 16px;
}
.rule-note,
.entry-guide {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}
.rule-note {
  margin-top: 22px;
}
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.eyebrow {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.game-top h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -1px;
}
.progress-wrap {
  margin: 22px 0;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.progress-track {
  height: 4px;
  border-radius: 5px;
  background: #e4e7db;
  overflow: hidden;
}
.progress-track i {
  display: block;
  height: 100%;
  background: #658259;
}
.game-grid {
  display: grid;
  gap: 18px;
}
.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fffef9;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 17px;
}
.panel-head h2 {
  font-size: 15px;
  margin: 0;
  letter-spacing: -0.4px;
}
.panel-head > span {
  font-size: 10px;
  color: var(--muted);
}
.standings {
  display: grid;
  gap: 9px;
}
.standing {
  display: grid;
  grid-template-columns: 29px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 11px 9px;
  border-radius: 10px;
  background: #f4f5ee;
}
.standing.rank-1 {
  background: #edf2e2;
}
.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 32px;
  border-radius: 7px;
  background: #dce5cd;
  color: #5b7550;
  font-size: 11px;
}
.standing-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
}
.standing-money {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.plus {
  color: #b55b3d;
}
.minus {
  color: #597c95;
}
.coin-stack {
  display: block;
  font-size: 8px;
  color: #bca464;
  letter-spacing: -1px;
  margin-top: 3px;
}
.field-label {
  display: grid;
  gap: 8px;
  font-size: 12px;
}
.field-label select {
  border: 1px solid var(--line);
  border-radius: 9px;
  height: 46px;
  padding: 0 10px;
  font-size: 16px;
  background: #fff;
  color: inherit;
}
.card-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.modifiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.check-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 8px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.check-card:has(input:checked) {
  border-color: #668159;
  background: #edf3e5;
}
.check-card input {
  width: 14px;
  height: 14px;
  accent-color: var(--green);
  margin: 0;
}
.check-card > span {
  display: none;
}
.check-card strong {
  display: block;
  font-size: 12px;
}
.check-card small {
  font-size: 10px;
  color: var(--muted);
}
.check-card select {
  font-size: 12px;
  border: 0;
  background: transparent;
  max-width: 100%;
  color: #6b7d61;
  min-height: 28px;
}
.modifier-title {
  margin-top: 22px;
  font-size: 12px;
}
.loser-details {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 16px;
}
.loser-details h3 {
  font-size: 12px;
  margin: 0 0 9px;
}
.loser-details h3 small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 6px;
}
.loser-detail {
  display: grid;
  grid-template-columns: 1fr 56px 64px 43px;
  gap: 5px;
  align-items: center;
  margin: 8px 0;
  font-size: 11px;
}
.loser-detail b {
  overflow-wrap: anywhere;
}
.loser-detail select {
  height: 44px;
  width: 100%;
  font-size: 12px;
  padding: 2px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.loser-detail label {
  font-size: 10px;
}
.loser-detail input {
  accent-color: var(--green);
}
.amount-preview {
  margin: 18px 0;
  padding: 14px;
  background: #f1f3e9;
  border-radius: 10px;
  display: grid;
  gap: 9px;
  font-size: 12px;
}
.amount-preview small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 5px;
}
.amount-preview b {
  font-size: 17px;
}
.history {
  margin-top: 18px;
}
.history .panel-head {
  margin-bottom: 6px;
}
.history-list.empty {
  padding: 25px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.history-item {
  padding: 13px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 45px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}
.history-round {
  color: var(--muted);
}
.history-main span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 5px;
}
.history-amount {
  color: #a3613c;
}
.finish-content {
  padding: 32px 24px;
}
.finish-content h2 {
  font-size: 27px;
  letter-spacing: -1px;
}
.finish-content p {
  color: var(--muted);
  font-size: 13px;
}
.finish-ranks {
  margin: 24px 0;
}
.finish-rank {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 600px) {
  .app-shell {
    margin: 28px auto;
    min-height: calc(100dvh - 56px);
    border-radius: 26px;
    box-shadow: 0 14px 70px #34442e0d;
    padding: 28px 30px;
  }
  .setup-dialog {
    width: min(440px, calc(100% - 24px));
    border-radius: 24px;
    top: calc(var(--visible-top) + var(--visible-height) / 2);
    transform: translateY(-50%);
  }
}
@media (max-width: 350px) {
  .app-shell {
    padding-left: 18px;
    padding-right: 18px;
  }
  .panel {
    padding: 14px;
  }
  .brand em {
    display: none;
  }
  .home-art {
    aspect-ratio: 1.5;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
