:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --bg: #100e19;
  --panel: #191624;
  --border: #30293d;
  --text: #f5f0fd;
  --muted: #b9afc8;
  --accent: #cbb5ff;
  --accent-strong: #d7c7ff;
  --danger: #ff9fb4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse 62rem 35rem at 50% 0%, #21172e, transparent 78%), var(--bg);
  color: var(--text);
}

h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.52; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.site-header { border-bottom: 1px solid #302739; background: #100e19b3; }

.header-inner {
  width: min(100% - 3rem, 68rem);
  min-height: 4.6rem;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  font-size: 1.125rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.brand-icon, .empty-icon { display: grid; place-items: center; }

.brand-icon {
  width: 2rem;
  height: 2rem;
  border: 1px solid #a58ad6;
  border-radius: 0.52rem;
  background: #372753;
  color: var(--accent-strong);
  font-family: Georgia, serif;
  font-size: 1.35rem;
  transform: rotate(-9deg);
}

.brand-icon span { transform: rotate(9deg); }
.header-actions, .dialog-actions { display: flex; gap: 0.55rem; }

.button {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.button-quiet {
  background: #201a2c;
  border-color: #3a3048;
  color: var(--muted);
}

.button-quiet:hover:not(:disabled) { background: #2b233b; color: var(--text); }
.button-admin.active { color: var(--accent-strong); border-color: #775ca9; }

.button-primary { background: var(--accent); color: #211237; }
.button-primary:hover:not(:disabled) { background: #e0d3ff; }

.lock-icon, .link-icon { position: relative; flex: none; width: 0.875rem; height: 0.875rem; }

.lock-icon::before, .lock-icon::after, .link-icon::before, .link-icon::after {
  content: "";
  position: absolute;
  border: 1.5px solid currentColor;
}

.lock-icon::before { inset: 0 0.22rem 0.34rem; border-radius: 0.24rem 0.24rem 0 0; }
.lock-icon::after { inset: 0.36rem 0.09rem 0; border-radius: 0.15rem; background: #201a2c; }
.link-icon { transform: rotate(-35deg); }
.link-icon::before, .link-icon::after { width: 0.55rem; height: 0.37rem; top: 0.25rem; border-radius: 1rem; }
.link-icon::before { left: -0.12rem; }
.link-icon::after { right: -0.12rem; }

.page {
  width: min(100% - 3rem, 68rem);
  margin-inline: auto;
  padding-block: clamp(2.1rem, 6vw, 4rem) 2rem;
}

.intro { margin-bottom: 1.85rem; }

.round-tag {
  width: fit-content;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.75rem;
  border-radius: 2rem;
  border: 1px solid #544167;
  background: #2b203a;
  color: #dfcbfc;
  font-size: 0.85rem;
  font-weight: 700;
}

.round-tag > span:first-child { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: #aea5bb; }
.round-tag.online > span:first-child { background: #cdb1ff; box-shadow: 0 0 0.55rem #b995fc80; }

.intro h1 {
  font-size: clamp(2rem, 6vw, 3.65rem);
  line-height: 1.16;
  letter-spacing: -0.06em;
  font-weight: 800;
}

.intro h1 span { color: #b592fe; }
.intro > p { margin-top: 0.72rem; color: var(--muted); font-size: 1rem; line-height: 1.55; }

.table-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: var(--panel);
  box-shadow: 0 1rem 3rem #09071038;
}

.play-panel { padding: clamp(0.9rem, 2.5vw, 1.35rem); }
.play-header, .people-header { display: flex; justify-content: space-between; align-items: center; gap: 0.65rem; }
.play-header { margin-bottom: 1rem; }
.panel h2, dialog h2 { font-size: 1.16rem; letter-spacing: -0.035em; }
.remaining, .player-count { font-size: 0.875rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; }

.card-table {
  position: relative;
  min-height: clamp(16.3rem, 34vw, 20rem);
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #3c2e4e;
  border-radius: 0.9rem;
  background:
    radial-gradient(ellipse at center, #4a3163ba, #251a33d9 74%),
    repeating-linear-gradient(120deg, #49345d 0 1px, transparent 1px 12px),
    #251a33;
}

.card-table::before {
  content: "";
  position: absolute;
  inset: 0.65rem;
  border: 1px solid #b68cf026;
  border-radius: 0.57rem;
  pointer-events: none;
}

.card {
  width: clamp(7.5rem, 16vw, 9rem);
  aspect-ratio: 5 / 7;
  perspective: 900px;
  position: relative;
  font-family: Georgia, "Times New Roman", serif;
}

.card::before, .card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid #9973c577;
  border-radius: 0.78rem;
  background: #3b2a56;
  box-shadow: 0 0.65rem 1.4rem #0f0a1c55;
  transition: opacity 0.3s, transform 0.45s;
}

.card::before { transform: translate(-1.16rem, 0.36rem) rotate(-13deg); }
.card::after { transform: translate(1.16rem, 0.36rem) rotate(13deg); }
.card.is-open::before, .card.is-open::after { transform: none; opacity: 0; }
.card-flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.55s ease; }
.card.is-open .card-flip { transform: rotateY(180deg); }

.card-side {
  position: absolute;
  inset: 0;
  border-radius: 0.78rem;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  box-shadow: 0 0.85rem 1.65rem #120b2190;
}

.card-back {
  border: 1px solid #af8fdf;
  color: #dfcdff;
  background:
    repeating-linear-gradient(45deg, #c7a8f72b 0 1px, transparent 1px 8px),
    repeating-linear-gradient(-45deg, #c7a8f727 0 1px, transparent 1px 8px),
    radial-gradient(at 40% 30%, #77539d, #3a2659);
}

.card-back::before, .card-back::after { content: ""; position: absolute; border: 1px solid #d8bdff98; }
.card-back::before { inset: 0.48rem; border-width: 2px; border-radius: 0.42rem; }
.card-back::after { inset: 0.76rem; border-radius: 0.25rem; }

.card-diamond {
  z-index: 1;
  width: 3.65rem;
  height: 3.65rem;
  display: grid;
  place-items: center;
  border: 1px solid #dcc4ffc2;
  border-radius: 0.48rem;
  background: #4a316b;
  box-shadow: 0 0 0 0.27rem #5a3c80d9, 0 0 0 0.35rem #b18bd7bb;
  transform: rotate(45deg);
}

.card-diamond span { font-size: 2.65rem; transform: rotate(-45deg); line-height: 1; }
.card-face { background: #fbf7fc; border: 1px solid #fff; color: #2d2239; transform: rotateY(180deg); }
.card.red .card-face { color: #a82048; }
.face-suit { font-size: clamp(3.1rem, 8.5vw, 4.35rem); line-height: 1; }
.card-corner { position: absolute; top: 0.58rem; left: 0.66rem; display: grid; justify-items: center; font-weight: 700; font-size: 1.2rem; line-height: 0.98; }
.card-corner-bottom { inset: auto 0.66rem 0.58rem auto; transform: rotate(180deg); }

.play-controls { padding-top: 1rem; }
.join-form, .draw-controls { width: min(100%, 28rem); margin-inline: auto; }

label {
  display: block;
  margin-bottom: 0.43rem;
  color: #e9def8;
  font-size: 0.9rem;
  font-weight: 700;
}

.join-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; }
.join-fields button { min-width: 5.3rem; }

input {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  border: 1px solid #463853;
  border-radius: 0.65rem;
  background: #14111d;
  font-size: 1rem;
}

input::placeholder { color: #a296b1; }
.draw-controls { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; min-height: 4.3rem; }
.draw-controls p { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }

.notice { color: var(--accent-strong); font-size: 0.875rem; line-height: 1.5; }
.notice:not(:empty) { margin-top: 0.65rem; }
.notice.error { color: var(--danger); }
.play-controls .notice { text-align: center; }
.page-status { text-align: right; }

.people-panel { min-height: 19rem; padding: 1.3rem; }
.people-header { align-items: flex-start; }
.people-header p { margin-top: 0.4rem; color: var(--muted); font-size: 0.9rem; }
.player-count { background: #2e233d; padding: 0.32rem 0.6rem; border-radius: 1rem; }

.empty-people {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.9rem;
  min-height: 12.7rem;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 2.7rem;
  height: 3.3rem;
  border: 1px dashed #725c8b;
  border-radius: 0.5rem;
  background: #251c33;
  color: #c5a8f1;
  font: 1.75rem Georgia, serif;
  transform: rotate(-11deg);
}

.empty-icon span { transform: rotate(11deg); }
.player-list { list-style: none; margin: 1.1rem 0 0; padding: 0; max-height: 25rem; overflow-y: auto; }

.player-row {
  min-height: 3.45rem;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.58rem;
  padding: 0.4rem 0.25rem;
  border-top: 1px solid var(--border);
}

.avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 0.58rem;
  background: #36284a;
  color: var(--accent-strong);
  font-size: 0.86rem;
}

.player-name { overflow-wrap: anywhere; }
.self { margin-inline-start: 0.4rem; color: var(--accent); font-size: 0.82rem; font-weight: 650; }
.draw-status { color: var(--muted); font-size: 0.875rem; }
.draw-status.drawn { color: var(--accent-strong); }

dialog {
  width: min(100% - 2rem, 25rem);
  padding: 1.3rem;
  border: 1px solid #514061;
  border-radius: 1rem;
  background: #21192d;
  color: var(--text);
  box-shadow: 0 1.5rem 4rem #06030dad;
}

dialog::backdrop { background: #100a17c9; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; }
.close-button { padding: 0.2rem 0.5rem; background: transparent; color: var(--muted); font-size: 1.65rem; }
#admin-form .button { width: 100%; margin-top: 0.75rem; }
#admin-controls > p { color: var(--muted); line-height: 1.55; }
.dialog-actions { justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 42rem) {
  .page, .header-inner { width: calc(100% - 2rem); }
  .header-inner { min-height: 4rem; }
  .table-layout { grid-template-columns: 1fr; gap: 1rem; }
  .people-panel { min-height: 14rem; padding: 1rem; }
  .empty-people { min-height: 8.5rem; }
  .intro { margin-bottom: 1.3rem; }
}

@media (max-width: 25rem) {
  .brand { gap: 0.5rem; font-size: 1rem; }
  .header-actions { gap: 0.35rem; }
  .header-actions .button { padding-inline: 0.53rem; font-size: 0.82rem; }
  .header-actions .button > span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
