/* ═══════════════════════════════════════════════════════════════
   King Play Ground — 디자인 토큰 + 공통 셸
   목업 기준: 딥레드 + 골드, 모바일 앱형(상단바 · 히어로 캐러셀 · 카테고리 그리드 · 하단 탭바).
   Tailwind CDN 없이 이 파일 하나로 스타일을 끝낸다.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* 브랜드 — 딥레드 */
  --red-900: #4a0708;
  --red-800: #5f0d0f;
  --red-700: #7a1416;
  --red-600: #931c1e;
  --red-ink: #8b1a1a; /* 섹션 제목용 */

  /* 골드 */
  --gold-300: #f3dda6;
  --gold-400: #e6c67e;
  --gold-500: #d4a24c;
  --gold-600: #b8862f;
  --gold-line: rgba(212, 162, 76, 0.45);

  /* 표면 */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #faf7f5;
  --border: rgba(74, 7, 8, 0.1);

  /* 텍스트 */
  --text-1: #1c0c0c;
  --text-2: #5c4444;
  --text-3: #8b7676;
  --on-red: #ffffff;

  /* 상태 */
  --danger: #c02626;
  --success: #1f7a4d;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(28, 12, 12, 0.1);
  --shadow-md: 0 4px 14px rgba(28, 12, 12, 0.12);
  --shadow-lg: 0 12px 32px rgba(28, 12, 12, 0.18);

  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --container: 1200px;

  --font-brand: "Playfair Display", "Times New Roman", serif;
  --font-ui: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17100f;
    --surface: #201615;
    --surface-2: #2a1d1c;
    --border: rgba(230, 198, 126, 0.14);
    --text-1: #f6ecec;
    --text-2: #c9b3b3;
    --text-3: #9a8484;
    --red-ink: #e6a4a4;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* 고정 상·하단 바가 콘텐츠를 가리지 않도록 */
  padding-top: var(--topbar-h);
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
}

body.no-bottomnav {
  padding-bottom: 0;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* ─── 상단바 ─────────────────────────────────────────────── */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--topbar-h);
  background: linear-gradient(180deg, var(--red-700), var(--red-900));
  border-bottom: 2px solid var(--gold-500);
  box-shadow: var(--shadow-md);
}

.topbar-inner {
  height: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-brand);
  font-size: clamp(18px, 4.5vw, 26px);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--gold-400);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* 상단바 잔액 칩 */
.balance-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--gold-line);
}

.balance-chip .amount {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold-300);
}

/* ─── 언어 선택기 ────────────────────────────────────────── */

.lang {
  position: relative;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--gold-line);
  box-shadow: var(--shadow-sm);
  line-height: 1;
}

.lang-toggle .flag {
  font-size: 16px;
}

.lang-toggle .globe {
  width: 18px;
  height: 18px;
  color: var(--red-700);
}

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 168px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-1);
  font-size: 14px;
  text-align: left;
}

.lang-item:hover {
  background: var(--surface-2);
}

.lang-item[aria-current="true"] {
  background: rgba(212, 162, 76, 0.16);
  font-weight: 600;
}

/* ─── 하단 탭바 ──────────────────────────────────────────── */

.bottomnav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 50;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: linear-gradient(180deg, var(--red-800), var(--red-900));
  border-top: 2px solid var(--gold-500);
  display: flex;
}

.bottomnav-inner {
  height: var(--bottomnav-h);
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.navtab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--gold-400);
  opacity: 0.75;
  border: 0;
  background: transparent;
}

.navtab svg {
  width: 24px;
  height: 24px;
}

.navtab .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.navtab:hover {
  opacity: 1;
}

.navtab[aria-current="page"] {
  opacity: 1;
  color: var(--gold-300);
}

/* ─── 섹션 · 게임 그리드 ─────────────────────────────────── */

.section {
  margin: 28px 0;
}

.section-title {
  margin: 0 0 12px;
  font-size: clamp(17px, 3.4vw, 22px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--red-ink);
}

.game-grid {
  display: grid;
  gap: 12px;
  /* 모바일 2열 → 데스크톱 4열(목업과 동일한 인상) */
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 600px) {
  .game-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .game-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.game-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.game-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.game-card .thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-2);
}

.game-card .meta {
  padding: 8px 10px 10px;
  text-align: left;
}

.game-card .title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card .subtitle {
  font-size: 11px;
  color: var(--text-3);
}

/* ─── 히어로 캐러셀 ──────────────────────────────────────── */

.hero {
  margin: 16px 0 8px;
}

.carousel {
  position: relative;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  gap: 12px;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.carousel-slide {
  flex: 0 0 100%;
  border-radius: var(--radius-lg);
  border: 2px solid var(--gold-500);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--red-800);
}

.carousel-slide img {
  width: 100%;
  aspect-ratio: 16 / 7;
  object-fit: cover;
}

.carousel-slide[data-provider] {
  cursor: pointer;
}

/* 배너 아트가 없을 때의 텍스트 슬라이드 */
.slide-text {
  aspect-ratio: 16 / 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  color: #fff;
}

.slide-text .s-title {
  font-family: var(--font-brand);
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--gold-300);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.slide-text .s-sub {
  font-size: clamp(12px, 2.6vw, 16px);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
}

.slide-red {
  background: radial-gradient(circle at 30% 30%, var(--red-600), var(--red-900) 70%);
}

.slide-gold {
  background: linear-gradient(135deg, #7a1416, #b8862f 55%, #4a0708);
}

.slide-dark {
  background: linear-gradient(135deg, #2a1d1c, #4a0708);
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 10px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(140, 120, 120, 0.35);
  transition: background 0.2s ease, width 0.2s ease;
}

.carousel-dot[aria-current="true"] {
  width: 20px;
  background: var(--gold-500);
}

/* ─── 버튼 ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-gold {
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
  color: #3a2408;
  border-color: var(--gold-600);
  box-shadow: var(--shadow-sm);
}

.btn-gold:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-red {
  background: linear-gradient(180deg, var(--red-600), var(--red-800));
  color: var(--on-red);
  border-color: var(--red-900);
}

.btn-red:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-block {
  width: 100%;
}

/* ─── 카드 · 폼 ──────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-title {
  margin: 0 0 4px;
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
}

.card-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-3);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-1);
  font-family: inherit;
  font-size: 15px;
}

.field input:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(212, 162, 76, 0.2);
}

.msg {
  margin: 10px 0 0;
  font-size: 13px;
}

.msg-error {
  color: var(--danger);
}

.msg-info {
  color: var(--gold-600);
}

/* ─── 모달 ───────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(28, 8, 8, 0.6);
  backdrop-filter: blur(3px);
}

.modal-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

/* ─── 토스트 · 오버레이 ──────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + 20px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(28, 8, 8, 0.92);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
}

.toast.is-error {
  background: var(--danger);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(28, 8, 8, 0.72);
  color: var(--gold-300);
  font-weight: 600;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(230, 198, 126, 0.25);
  border-top-color: var(--gold-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── 목록(거래내역) ─────────────────────────────────────── */

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.list-row .left {
  min-width: 0;
}

.list-row .type {
  font-size: 14px;
  font-weight: 700;
}

.list-row .when {
  font-size: 11px;
  color: var(--text-3);
}

.list-row .right {
  text-align: right;
  flex-shrink: 0;
}

.list-row .delta {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.delta-plus {
  color: var(--success);
}

.delta-minus {
  color: var(--danger);
}

.list-row .after {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ─── 인증 페이지(로그인/가입) ───────────────────────────── */

.auth-wrap {
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--red-900), #2a0405 60%, #140203);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 20px;
}

.auth-brand .name {
  font-family: var(--font-brand);
  font-size: 26px;
  font-weight: 700;
  color: var(--red-ink);
}

.auth-brand .tag {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.auth-alt {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.auth-alt a {
  color: var(--gold-600);
  font-weight: 600;
}
