:root {
  color-scheme: dark;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", sans-serif;
  color: #eeeae0;
  background: #0b1e1a;
  --ink: #eeeae0;
  --muted: #a7b6ad;
  --gold: #e8c784;
  --gold-light: #f4dba5;
  --hairline: #30443a;
  --surface: #102722;
  --table-line: #63867850;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100svh; background: radial-gradient(ellipse at 48% 10%, #112b24, transparent 76%); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 4px; }
h1, h2, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }

.site-header { border-bottom: 1px solid #263d33; background: #0a1b17b5; }
.header-content, .game { max-width: 1440px; margin-inline: auto; padding-inline: clamp(16px, 4.4vw, 64px); }
.header-content { min-height: 79px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand, .header-actions, .game-actions, .button { display: flex; align-items: center; }
.brand { gap: 13px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 41px;
  height: 42px;
  border: 1px solid #b69257;
  border-radius: 11px;
  background: linear-gradient(145deg, #292e20, #17251b);
  box-shadow: inset 0 0 0 3px #16281e;
  color: var(--gold);
  font: 27px/1 Georgia, serif;
}
.brand h1 { font-size: clamp(17px, 2vw, 24px); font-weight: 700; letter-spacing: -.055em; line-height: 1.35; }
.header-actions, .game-actions { gap: 10px; }

.button {
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 14px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.button.primary {
  color: #272116;
  background: linear-gradient(155deg, #f4d89d, #dabc79);
  border-color: #edcf93;
  box-shadow: 0 1px 3px #0003, inset 0 1px #fff4;
}
.button.primary:hover { background: var(--gold-light); }
.button.quiet { color: #c1cac2; }
.button.quiet:hover { background: #fff1; }
.button.secondary { background: #142a24; border-color: var(--hairline); }
.button.secondary:hover:enabled { background: #20392f; border-color: #587062; }
.button:disabled { color: #74877e; }
.plus-icon, .undo-icon { font-family: system-ui, sans-serif; font-size: 20px; line-height: 1; font-weight: 400; }
.help-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 600 11px/1 system-ui, sans-serif;
}
.bulb-icon { position: relative; width: 11px; height: 12px; border: 1.4px solid currentColor; border-radius: 65% 65% 43% 43%; margin: 0 2px 4px; }
.bulb-icon::after { content: ""; position: absolute; inset: auto 2px -4px; border-bottom: 1.4px solid currentColor; }

.game { padding-top: 27px; padding-bottom: 24px; }
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 23px; }
.metrics { display: flex; align-items: center; }
.metrics div { min-width: 94px; padding-inline: 21px; }
.metrics div:first-child { padding-left: 0; min-width: 72px; }
.metrics div + div { border-left: 1px solid #33483e; }
.metrics dt { color: var(--muted); font-size: 13px; line-height: 1.5; }
.metrics dd {
  margin-top: 2px;
  font: 600 23px/1.2 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.metrics div:first-child dd { color: var(--gold-light); }

.table {
  position: relative;
  z-index: 0;
  min-height: max(490px, calc(100svh - 258px));
  padding: clamp(19px, 2.7vw, 38px);
  overflow: hidden;
  border: 1px solid #57796a;
  border-radius: 23px;
  background:
    repeating-linear-gradient(36deg, #00201813 0 1px, transparent 1px 4px),
    repeating-linear-gradient(126deg, #c2ead70a 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at 47% 32%, #2b644d, #204d3c 58%, #143c30 100%);
  box-shadow: inset 0 0 37px #072c2280, 0 14px 36px #010e0b62;
}
.table::before {
  position: absolute;
  z-index: -1;
  content: "";
  inset: 8px;
  border: 1px solid #d2dbb331;
  border-radius: 16px;
  pointer-events: none;
}
.table::after {
  position: absolute;
  z-index: -1;
  bottom: 11%;
  left: 50%;
  display: grid;
  place-items: center;
  width: clamp(74px, 8.5vw, 122px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border: 1px solid #e9d49c26;
  border-radius: 50%;
  box-shadow: 0 0 0 5px #244f3e32, 0 0 0 6px #e9d49c17;
  color: #e9d49c2e;
  font: clamp(38px, 5vw, 72px)/1 Georgia, serif;
  content: "♠";
  pointer-events: none;
}
.table-content { min-width: 0; }
.table-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 23px;
  border-bottom: 1px solid var(--table-line);
}
.table-label { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.table-label h2 { font: inherit; }
.table-count, .stock-count { color: #c0d1c6; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.foundation-slots { display: flex; gap: clamp(4px, .65vw, 9px); margin-top: 9px; }
.foundation-slot {
  display: grid;
  place-items: center;
  width: clamp(28px, 3.1vw, 44px);
  aspect-ratio: .85;
  border: 1px dashed #b7c9b87a;
  border-radius: 7px;
  color: #daf0d9a1;
  background: #15392c3c;
  font: 21px/1 Georgia, serif;
}
.foundation-slot.filled {
  border: 1px solid #d1ae70;
  color: #332c21;
  background: linear-gradient(150deg, #f5e1ad, #d6b575);
  box-shadow: inset 0 0 0 3px #edcf91, 0 2px 5px #123125c2;
}
.foundation-slot.red { color: #a33236; }

.stock {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 15px);
  min-height: 58px;
  padding: 5px 6px 5px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}
.stock:hover:enabled { border-color: #c2d3ba49; background: #082c2041; }
.stock:disabled { opacity: .55; }
.stock-copy { display: grid; justify-items: end; gap: 5px; }
.stock .stock-art {
  display: grid;
  place-items: center;
  width: 45px;
  height: 62px;
  border-radius: 6px;
  box-shadow: 3px -2px 0 -1px #273e5c, 4px -3px 0 -1px #d7d9d7, 6px -4px 0 -1px #273e5c, 7px -5px 0 -1px #d7d9d7;
}
.stock-art span { color: #f4f2e9; font: 24px/1 Georgia, serif; }
.stock.stock-hint { background: #d5b56a24; border-color: var(--gold); }
.game-footer { display: flex; gap: 11px 20px; align-items: baseline; justify-content: space-between; padding-top: 17px; }
.status { color: var(--muted); font-size: 14px; line-height: 1.65; }
.difficulty { color: #c0c8b9; flex-shrink: 0; font-size: 13px; }
.difficulty::before { content: "♠"; margin-right: 7px; color: var(--gold); }

dialog {
  width: min(480px, calc(100% - 30px));
  max-height: calc(100svh - 30px);
  border: 1px solid #53796a;
  border-radius: 18px;
  padding: 24px;
  background: #142d25;
  color: var(--ink);
  box-shadow: 0 24px 68px #040d0bd1;
}
dialog::backdrop { background: #05110ce0; }
dialog form { display: grid; gap: 18px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { font-size: 21px; }
dialog p, .rules { color: #cbd6cb; line-height: 1.65; font-size: 15px; }
.button.close { padding-inline: 10px; font-size: 27px; line-height: 1; color: #cbd6cb; }
.button.close:hover { background: #ffffff12; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 4px;
  border: 1px solid #4a685b;
  border-radius: 11px;
  background: #1d3a2f;
}
.level:hover { border-color: var(--gold); background: #2d493a; }
.level-suits { color: var(--gold-light); font: clamp(14px, 3.5vw, 21px)/1.4 Georgia, serif; white-space: nowrap; }
.level strong { font-size: 15px; }
.level span:last-child, .dialog-note { color: #bccbc0; font-size: 13px; }
.rules { margin: 0; padding-left: 22px; }
.rules li + li { margin-top: 10px; }
.dialog-action { justify-self: end; }
#win-dialog[open] { animation: win-appear .28s ease-out both; }
@keyframes win-appear {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #win-dialog[open] { animation: none; }
}

@media (max-width: 700px) {
  .header-content { min-height: 65px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 33px; border-radius: 8px; font-size: 21px; }
  .header-actions, .game-actions { gap: 6px; }
  .button { padding-inline: 10px; gap: 5px; font-size: 13px; }
  .game { padding-top: 21px; }
  .game-bar { margin-bottom: 17px; gap: 7px; }
  .metrics div { min-width: 52px; padding-inline: 10px; }
  .metrics div:first-child { min-width: 43px; }
  .metrics dt { font-size: 12px; }
  .metrics dd { font-size: 19px; }
  .table { padding: 16px 11px; min-height: max(425px, calc(100svh - 245px)); border-radius: 15px; }
  .table::before { inset: 4px; border-radius: 11px; }
  .table-bar { padding-bottom: 14px; margin-bottom: 16px; gap: 6px; }
  .table-label { font-size: 13px; gap: 6px; }
  .table-count, .stock-count { font-size: 12px; }
  .stock { gap: 7px; min-height: 48px; padding: 4px 2px 4px 4px; }
  .stock .stock-art { width: 31px; height: 44px; }
  .stock-art span { font-size: 19px; }
  .foundation-slot { font-size: 15px; border-radius: 5px; }
  .game-footer { flex-wrap: wrap; padding-top: 12px; }
  .status { font-size: 13px; }
  .difficulty { font-size: 12px; }
}
@media (max-width: 460px) {
  .game { padding-inline: 10px; }
  .header-content { padding-inline: 10px; gap: 7px; }
  .header-actions .button { padding-inline: 7px; }
  .button.quiet .help-icon { display: none; }
  .brand h1 { font-size: clamp(14px, 4.1vw, 18px); }
  .foundation-slot { width: clamp(16px, 5.6vw, 26px); }
  .foundation-slots { gap: 3px; }
}
@media (max-width: 335px) {
  .game-actions .button { padding-inline: 6px; }
  .brand-mark { display: none; }
}
