:root {
  --bg: #f3ebda;
  --panel: rgba(255, 252, 245, 0.9);
  --line: rgba(89, 55, 16, 0.18);
  --text: #2d1d12;
  --muted: #7a6654;
  --gold: #ab7a18;
  --wine: #7f2d2d;
  --green: #36513c;
  --shadow: 0 24px 60px rgba(74, 45, 16, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans KR", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 28%),
    radial-gradient(circle at top right, rgba(171, 122, 24, 0.15), transparent 24%),
    linear-gradient(180deg, #efe3c5 0%, var(--bg) 45%, #e8dbc0 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  padding: 24px 12px 18px;
}

.eyebrow,
.panel-kicker,
.mini-label,
.helper,
.selection-hint,
.spotlight-type {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.panel-kicker,
.helper,
.selection-hint,
.mini-label,
.spotlight-type {
  color: var(--muted);
  font-size: 0.78rem;
}

.hero h1,
.panel h2,
.subpanel h3,
.card-name,
.card-rank,
.badge,
.selected-count,
.spotlight-card h2 {
  font-family: "Cinzel", serif;
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(2.2rem, 5vw, 4rem);
  letter-spacing: 0.04em;
}

.hero-copy {
  margin: 0;
  max-width: 48rem;
  color: #4e3d2e;
}

.layout {
  display: grid;
  gap: 18px;
}

.panel,
.subpanel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel {
  padding: 24px;
}

.subpanel {
  padding: 18px;
}

.auth-panel {
  max-width: 520px;
}

.panel-head,
.subpanel-head,
.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}


.auth-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(127, 45, 45, 0.08);
  border: 1px solid rgba(127, 45, 45, 0.18);
  color: #6f2626;
}

.auth-feedback.info {
  background: rgba(171, 122, 24, 0.1);
  border-color: rgba(171, 122, 24, 0.2);
  color: #7b5510;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(89, 55, 16, 0.2);
  background: rgba(255, 255, 255, 0.85);
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.auth-actions.split > * {
  flex: 1;
}

.divider {
  position: relative;
  margin: 22px 0 4px;
  text-align: center;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--line);
}

.divider span {
  position: relative;
  padding: 0 10px;
  background: var(--panel);
  color: var(--muted);
}

.button {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.button.primary {
  background: linear-gradient(135deg, #b98826, #8a6216);
  color: #fffaf2;
}

.button.secondary {
  background: #e4d4b7;
  color: var(--text);
}

.button.ghost {
  background: rgba(89, 55, 16, 0.08);
  color: var(--text);
}

.button.danger {
  background: linear-gradient(135deg, #8d3333, #611f1f);
  color: white;
}

.room-panel {
  display: grid;
  gap: 18px;
}

.room-meta,
.hand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(171, 122, 24, 0.14);
  border: 1px solid rgba(171, 122, 24, 0.2);
}

.badge.muted {
  background: rgba(89, 55, 16, 0.08);
  border-color: rgba(89, 55, 16, 0.14);
}

.status-banner {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 247, 226, 0.95), rgba(233, 218, 188, 0.95));
  border: 1px solid rgba(171, 122, 24, 0.18);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
}

.roster-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.roster-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(89, 55, 16, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.roster-item.current-user {
  border-color: rgba(171, 122, 24, 0.4);
  background: rgba(255, 249, 234, 0.95);
}

.role-pill,
.cards-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.role-pill {
  background: rgba(171, 122, 24, 0.12);
}

.cards-pill {
  background: rgba(54, 81, 60, 0.1);
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.table-card,
.notice,
.selected-panel {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(89, 55, 16, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

.table-card.emphasis {
  background: linear-gradient(135deg, rgba(255, 248, 232, 0.95), rgba(244, 227, 188, 0.95));
  border-color: rgba(171, 122, 24, 0.24);
}

.action-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.result-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(54, 81, 60, 0.18);
  background: linear-gradient(135deg, rgba(241, 248, 239, 0.95), rgba(220, 236, 216, 0.95));
}

.result-list {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.result-rank {
  font-family: "Cinzel", serif;
}

.result-role {
  color: var(--muted);
  font-size: 0.9rem;
}

.notice strong {
  display: block;
  margin-bottom: 8px;
  font-family: "Cinzel", serif;
}

.hand-panel {
  overflow: hidden;
}

.selected-panel {
  margin-top: 18px;
  background: linear-gradient(135deg, rgba(255, 248, 233, 0.96), rgba(244, 231, 200, 0.96));
  border-color: rgba(171, 122, 24, 0.25);
}

.selected-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.selected-cards.empty-state {
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border: 1px dashed rgba(89, 55, 16, 0.18);
  border-radius: 16px;
  color: var(--muted);
  padding: 16px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(127, 45, 45, 0.08);
  border: 1px solid rgba(127, 45, 45, 0.14);
}

.selected-mark {
  font-size: 1rem;
}

.selected-count {
  color: var(--wine);
}

.hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
  min-height: 220px;
}

.hand-cards.empty-state {
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1px dashed rgba(89, 55, 16, 0.18);
  border-radius: 22px;
  padding: 24px;
}

.play-card {
  position: relative;
  width: 118px;
  min-height: 170px;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid rgba(89, 55, 16, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 237, 221, 0.98)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(171, 122, 24, 0.08));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.75),
    0 14px 28px rgba(74, 45, 16, 0.14);
  display: grid;
  align-content: space-between;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  flex: 0 0 auto;
}

.play-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 14px;
  border: 1px solid rgba(89, 55, 16, 0.12);
  pointer-events: none;
}

.play-card::after {
  content: "선택됨";
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(127, 45, 45, 0.9);
  color: white;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.play-card:hover:not(:disabled) {
  transform: translateY(-4px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.85),
    0 18px 34px rgba(74, 45, 16, 0.2);
}

.play-card.selected {
  transform: translateY(-8px) scale(1.03);
  border: 2px solid rgba(171, 122, 24, 0.78);
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 214, 0.95),
    0 22px 36px rgba(120, 82, 20, 0.28),
    0 0 0 5px rgba(171, 122, 24, 0.16);
}

.play-card.selected::after {
  opacity: 1;
  transform: translateY(0);
}

.play-card:disabled {
  cursor: default;
}

.card-corners {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}

.card-rank {
  font-size: 1.5rem;
}

.card-rank.right {
  transform: rotate(180deg);
}

.card-body {
  position: relative;
  z-index: 1;
  text-align: center;
  display: grid;
  gap: 8px;
}

.card-name {
  font-size: 1rem;
  line-height: 1.15;
}

.card-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.card-mark {
  font-size: 2rem;
}

.rank-1 .card-mark,
.rank-2 .card-mark,
.rank-3 .card-mark {
  color: var(--wine);
}

.rank-4 .card-mark,
.rank-5 .card-mark,
.rank-6 .card-mark {
  color: #915d0c;
}

.rank-7 .card-mark,
.rank-8 .card-mark,
.rank-9 .card-mark {
  color: #556c35;
}

.rank-10 .card-mark,
.rank-11 .card-mark,
.rank-12 .card-mark,
.rank-0 .card-mark {
  color: #315068;
}

.rank-0 {
  background:
    linear-gradient(180deg, rgba(254, 252, 255, 0.98), rgba(239, 233, 244, 0.98)),
    linear-gradient(135deg, rgba(127, 45, 45, 0.08), rgba(54, 81, 60, 0.08));
}

.spotlight {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(45, 29, 18, 0.18);
  pointer-events: none;
  z-index: 40;
}

.spotlight-card {
  min-width: min(92vw, 520px);
  max-width: 520px;
  padding: 26px 28px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 249, 236, 0.98), rgba(244, 228, 193, 0.98));
  border: 1px solid rgba(171, 122, 24, 0.28);
  box-shadow: 0 30px 80px rgba(74, 45, 16, 0.28);
  text-align: center;
  animation: spotlightIn 260ms ease;
}

.spotlight-card h2 {
  margin: 8px 0 10px;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.spotlight-card p {
  margin: 0;
}

.spotlight-turn {
  margin-bottom: 10px !important;
  color: #6f5222;
  font-weight: 700;
}

#spotlightBody {
  white-space: pre-line;
}

@keyframes spotlightIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .table-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: 180px;
  }

  .app-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 20px;
  }

  .panel,
  .subpanel {
    padding: 18px;
    border-radius: 22px;
  }

  .room-head,
  .subpanel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .room-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .selected-panel {
    position: sticky;
    bottom: 126px;
    z-index: 15;
    box-shadow: 0 16px 28px rgba(74, 45, 16, 0.14);
  }

  .hand-actions {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 25;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    border-radius: 20px;
    background: rgba(255, 250, 240, 0.96);
    border: 1px solid rgba(89, 55, 16, 0.12);
    box-shadow: 0 20px 40px rgba(74, 45, 16, 0.22);
    backdrop-filter: blur(10px);
  }

  .hand-actions .button {
    min-height: 44px;
    padding: 10px 12px;
  }

  .hand-cards {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 10px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .play-card {
    width: 136px;
    min-width: 136px;
    scroll-snap-align: start;
  }

  .play-card.selected {
    transform: translateY(-6px) scale(1.02);
  }

  .spotlight-card {
    padding: 22px 18px;
  }
}
