/* 갓스 플랜 공통 테마 — 짙은 갈색(호두나무) · 골드 · 상아색.
   금빛이 드는 대리석 성당(배경 이미지)에 갈색을 덮고, 호두나무색 패널 위에 상아색 글자와 금색 강조를 쓴다.
   (검은 테마는 너무 어둡고 흰 테마는 너무 밝다는 의견으로 그 중간으로 정했다.)
   게임별 화면(/games/<id>/style.css)은 여기의 변수(--gold, --panel …)를 가져다 쓴다. */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700;900&family=Hahmlet:wght@500;600;700;800&display=swap');
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  /* 글자 */
  --ink: #F8EFDC;         /* 본문 글자(상아색) */
  --soft: #EADDC3;
  --muted: #D2C2A4;
  --dim: #AE9D80;
  --deep: #2B1F06;        /* 금 버튼 위의 글자 */
  /* 금 */
  --gold: #EBCB7C;        /* 글자·선 */
  --gold-fill: #E7C873;   /* 면 */
  --gold-hi: #FFF1C2;
  --gold-deep: #9A7424;
  --gold-bg: rgba(231, 200, 115, .26);
  --metal: linear-gradient(180deg, #FFF3C8 0%, #EBCB78 30%, #C59A3A 56%, #A27C22 62%, #DDBB63 84%, #F7E3A1 100%);
  /* 면: 모두 갈색 계열 */
  --panel: rgba(64, 44, 27, .86);     /* 호두나무 패널 */
  --panel-2: rgba(86, 61, 39, .92);
  --card: #6A4B30;        /* 버튼·카드(패널보다 한 단계 밝은 갈색) */
  --well: #3A2718;        /* 움푹 들어간 칸 */
  --line: rgba(235, 203, 124, .40);
  --line-2: rgba(248, 239, 220, .16);
  --walnut: linear-gradient(180deg, #4A3320 0%, #2F1F12 100%);
  --on-walnut: #F8EFD9;
  /* 뜻이 있는 색 */
  --last: #B4C8FF;        /* 나중 된 자 */
  --last-fill: #5B7BD6;
  --err: #FFA89B;
  --err-fill: rgba(140, 40, 30, .55);
  --red: #C8432F;
  --ok: #9BDCA8;
  --ok-fill: #3F9A62;
  --shadow: 0 10px 28px rgba(25, 14, 5, .5);
  /* 글꼴: 제목은 한글 세리프(함렛), 영문·숫자 표제는 로마 비문체(Cinzel), 본문은 프리텐다드 */
  --f-display: 'Hahmlet', 'Noto Serif KR', 'AppleMyungjo', serif;
  --f-latin: 'Cinzel', 'Hahmlet', serif;
  --f-ui: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; }
html { background: #3A2718; }
body {
  margin: 0; color: var(--ink); font-family: var(--f-ui); font-weight: 500; letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background: #3A2718 center / cover no-repeat fixed;
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; text-wrap: balance; }
b, strong { font-weight: 700; }

/* 버튼과 입력: 기본은 밝은 호두나무, 중요한 것은 금속 */
button, input {
  font: inherit; font-weight: 600; color: var(--ink); border-radius: 12px; padding: 12px 16px;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .22), inset 0 -2px 0 rgba(20, 10, 2, .35), 0 4px 10px rgba(25, 14, 5, .35);
}
button { cursor: pointer; transition: transform .08s ease, filter .15s ease; }
button:active { transform: translateY(1px) scale(.985); filter: brightness(1.15); }
button:disabled { cursor: default; opacity: .5; }
input { background: #FBF5E8; color: #2C2013; box-shadow: inset 0 2px 5px rgba(60, 40, 15, .22); border-color: var(--gold-deep); }
input::placeholder { color: #A39378; font-weight: 500; }
input:focus, button:focus-visible { outline: 2px solid var(--gold-fill); outline-offset: 2px; }
.err { color: var(--err); min-height: 1.2em; font-weight: 700; }
.msg { color: var(--muted); }

.primary, .keys .sel {
  color: var(--deep); background: var(--metal); border: 1px solid #7A5912; font-family: var(--f-display); font-weight: 800;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), inset 0 -2px 0 rgba(80, 56, 8, .5), 0 6px 16px rgba(110, 80, 20, .35);
}
.primary { width: 100%; padding: 18px; font-size: 19px; }
.primary:disabled { box-shadow: none; }
.danger { border-color: rgba(255, 168, 155, .55); color: var(--err); background: rgba(120, 36, 26, .6); }

/* 큰 제목과 결과 문구 */
.result { font-family: var(--f-display); font-size: 1.45em; font-weight: 800; letter-spacing: -.02em; color: var(--gold); }
.host h1 { color: #FBE7B0; }

/* 로고(검은 바탕 이미지라 갈색 띠 위에 screen 으로 얹는다) */
.brand { display: block; mix-blend-mode: screen; pointer-events: none; user-select: none; }

/* 진행 표시줄: 지금 단계 + 남은 시간 */
.stagebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 16px; color: var(--gold); font-family: var(--f-display); font-weight: 700; letter-spacing: .02em; }
.stagebar b { font-family: var(--f-latin); font-weight: 700; color: var(--gold-hi); font-variant-numeric: tabular-nums lining-nums; letter-spacing: .04em; }

/* 숫자판(빛의 저울 등 여러 게임이 쓴다) */
.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.keys button { padding: 18px 0; font-family: var(--f-latin); font-size: 21px; font-weight: 700; font-variant-numeric: lining-nums; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.row button { flex: 1; }
.tap { width: 100%; height: 50vh; font-size: 48px; font-weight: 800; background: var(--metal); color: var(--deep); border: 0; user-select: none; -webkit-user-select: none; }

/* 순위표 */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 28px; }
.board li { display: grid; grid-template-columns: 60px 1fr auto; gap: 16px; align-items: center; padding: 11px 20px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-family: var(--f-display); font-weight: 700; }
.board li.off { opacity: .5; }
.board .rank { font-family: var(--f-latin); font-weight: 900; color: var(--gold); font-variant-numeric: lining-nums; }
.board .score { font-family: var(--f-latin); font-weight: 700; font-variant-numeric: tabular-nums lining-nums; color: #FFE9A8; display: inline-flex; align-items: center; gap: .35em; }
.board .score::after { content: ''; width: .95em; height: .95em; border-radius: 50%; background: url(/theme/assets/coin.jpg) center / 112%; box-shadow: 0 1px 3px rgba(60, 40, 15, .5); }
.board li.win { background: linear-gradient(90deg, rgba(150, 112, 40, .9), rgba(110, 78, 34, .9)); border-color: var(--gold); box-shadow: 0 0 0 2px rgba(231, 200, 115, .6), var(--shadow); }
.board.last li { background: rgba(52, 52, 78, .86); border-color: rgba(180, 200, 255, .32); }
.board.last .rank { color: var(--last); }
.divide { display: flex; align-items: center; gap: 14px; width: fit-content; min-width: 40%; margin: 16px 0 10px; padding: 4px 16px 4px 6px; border-radius: 99px; background: var(--panel); font-family: var(--f-display); font-weight: 800; letter-spacing: .08em; color: var(--last); }
.divide.first { color: var(--gold); }
.divide::before { content: ''; width: 1.5em; height: 1.5em; border-radius: 50%; background: url(/theme/assets/emblem-last.jpg) center / cover; box-shadow: 0 2px 6px rgba(60, 40, 15, .45); flex: none; }
.divide.first::before { background-image: url(/theme/assets/emblem-first.jpg); }
.divide::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, currentColor, transparent); opacity: .5; }

/* 입장 대기의 이름표: 흰 대리석 명패 */
.chips { display: flex; flex-wrap: wrap; gap: 10px; font-size: 24px; }
.chips span { padding: 7px 18px; border-radius: 6px; font-family: var(--f-display); font-weight: 700; color: #33271A; background: url(/theme/assets/marble-light.jpg) center / 220px; border: 1px solid rgba(138, 100, 16, .45); box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgba(80, 60, 30, .25), 0 4px 10px rgba(60, 40, 15, .22); }
.chips .off { opacity: .5; }

/* 규칙 설명 */
.rulespage { font-size: 32px; }
.rulespage h1 { font-size: 1.6em; margin: 0 0 .45em; }
.rules { counter-reset: r; list-style: none; font-size: 1em; line-height: 1.45; margin: 0; padding: .7em 1em; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-family: var(--f-display); font-weight: 600; }
.rules li { counter-increment: r; display: grid; grid-template-columns: 2.2em 1fr; align-items: baseline; }
.rules li::before { content: counter(r, upper-roman); font-family: var(--f-latin); font-weight: 700; font-size: .8em; color: var(--gold); letter-spacing: .04em; }
.rules li + li { margin-top: .22em; padding-top: .22em; border-top: 1px solid var(--line-2); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.teams > div { padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 22px; }
.teams b { font-family: var(--f-display); display: inline-flex; align-items: center; gap: .45em; }
.teams b::before { content: ''; width: 1.5em; height: 1.5em; border-radius: 50%; background: center / cover; box-shadow: 0 2px 6px rgba(60, 40, 15, .45); }
.teams .team-first::before { background-image: url(/theme/assets/emblem-first.jpg); }
.teams .team-last::before { background-image: url(/theme/assets/emblem-last.jpg); }
.teams ol { list-style: none; margin: 6px 0 0; padding: 0; color: var(--soft); display: flex; flex-wrap: wrap; gap: 2px 14px; }
.teams li { white-space: nowrap; }
.teams li i { font-style: normal; font-family: var(--f-latin); color: var(--dim); margin-right: 5px; font-variant-numeric: tabular-nums; }
.team-first { color: var(--gold); }
.team-last { color: var(--last); }
.bignum { font-family: var(--f-latin); font-size: 120px; font-weight: 900; margin: 24px 0 0; font-variant-numeric: tabular-nums lining-nums; color: var(--gold-hi); text-shadow: 0 3px 0 rgba(40, 24, 4, .8); }
.fallback { white-space: pre-wrap; word-break: break-all; font-size: 12px; color: var(--dim); }

/* ───────── 폰 ───────── */
.phone {
  padding: 0 16px 28px; max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; touch-action: manipulation;
  background-image: linear-gradient(180deg, rgba(58, 39, 24, .30) 0%, rgba(58, 39, 24, .72) 30%, rgba(52, 35, 21, .93) 56%, #33220F 100%), url(/theme/assets/dark/bg-hall-tall.jpg);
  background-position: center top; background-size: cover, 100% auto; background-repeat: no-repeat; background-attachment: scroll;
}
/* 위쪽 갈색 띠: 로고 */
.top { background: var(--walnut); margin: 0 -16px 10px; padding: 8px 0 6px; box-shadow: 0 4px 14px rgba(60, 40, 15, .35), inset 0 -2px 0 rgba(231, 200, 115, .7); }
.top .brand { width: 46%; max-width: 210px; margin: 0 auto; }
.phone form { display: grid; gap: 12px; }
.conn { background: rgba(120, 36, 26, .85); border: 1px solid rgba(255, 168, 155, .55); color: var(--err); padding: 8px 12px; border-radius: 10px; margin: 10px 0 12px; text-align: center; font-weight: 700; }
.me { font-size: 15px; display: flex; align-items: center; white-space: nowrap; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.me #myName { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-family: var(--f-display); font-size: 17px; }
.me .rest { flex: none; white-space: pre; color: var(--muted); }
.me #myTalent { font-family: var(--f-latin); font-weight: 700; color: var(--gold); }
.phone .stagebar { font-size: 15px; margin: 12px 2px 14px; }
.phone .stagebar b { font-size: 22px; }

/* 입장 화면 */
#join { display: grid; align-content: center; min-height: 100dvh; text-align: center; }
#join[hidden], #game[hidden] { display: none; }
#join .top { margin: 0 0 22px; padding: 28px 8% 24px; border-radius: 16px; box-shadow: var(--shadow), inset 0 0 0 1px rgba(231, 200, 115, .6); }
#join .top .brand { width: 100%; max-width: none; }
#join h1 { font-size: 30px; margin: 0 0 6px; }
#join .lead { margin: 0 0 22px; color: var(--muted); font-family: var(--f-display); font-weight: 600; }
#join input { padding: 16px; font-size: 18px; text-align: center; }
#join button { padding: 17px; font-size: 19px; color: var(--deep); background: var(--metal); border: 1px solid #7A5912; font-family: var(--f-display); font-weight: 800; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), inset 0 -2px 0 rgba(80, 56, 8, .5), 0 6px 16px rgba(110, 80, 20, .35); }
/* 게임이 아닌 구간(대기, 규칙 설명, 순위표)의 안내 문구는 가운데 큰 글씨로 */
.phone #view > p.msg:only-child, .phone #view > p.msg:first-child:nth-last-child(-n+3), .phone #view > p.msg:first-child:nth-last-child(-n+3) ~ p.msg { text-align: center; font-family: var(--f-display); font-weight: 700; font-size: 19px; line-height: 1.5; color: var(--ink); }
.phone #view > p.msg:first-child:nth-last-child(-n+3) { margin-top: 20vh; }

/* ───────── 공용 화면 ───────── */
.host {
  display: grid; grid-template-columns: 1fr; gap: 0; padding: 96px 44px 34px; min-height: 100vh;
  background-image: radial-gradient(120% 100% at 50% 34%, rgba(74, 50, 30, .22) 0%, rgba(62, 42, 25, .56) 55%, rgba(46, 30, 17, .86) 100%), url(/theme/assets/dark/bg-hall.jpg);
}
.host[data-phase='lobby'] { background-image: radial-gradient(110% 100% at 55% 45%, rgba(74, 50, 30, .30) 0%, rgba(62, 42, 25, .58) 60%, rgba(46, 30, 17, .85) 100%), url(/theme/assets/bg-gate.jpg); }
.host[data-phase='final'] { background-image: radial-gradient(120% 100% at 50% 26%, rgba(74, 50, 30, .20) 0%, rgba(62, 42, 25, .52) 55%, rgba(46, 30, 17, .84) 100%), url(/theme/assets/dark/bg-dawn.jpg); }
.host main { min-width: 0; }
/* 위쪽 갈색 띠: 로고 · 지금 단계 · 남은 시간 */
.host::before { content: ''; position: fixed; left: 0; right: 0; top: 0; height: 72px; background: var(--walnut); box-shadow: 0 4px 18px rgba(60, 40, 15, .4), inset 0 -2px 0 rgba(231, 200, 115, .7); z-index: 1; }
.host .brand { position: fixed; left: 34px; top: 8px; width: 216px; z-index: 2; }
.host .stagebar { position: fixed; left: 280px; right: 40px; top: 0; height: 72px; margin: 0; z-index: 2; font-size: 22px; color: #F3DC9B; }
.host .stagebar b { font-size: 42px; line-height: 1; color: #FFF1C2; text-shadow: 0 0 18px rgba(255, 215, 120, .5); }
.host h1 { font-size: 50px; margin: 0 0 22px; }
.host .result { font-size: 42px; }
.host .msg { font-size: 24px; }
/* 게임이 진행되는 동안에는 게임 화면 전체를 갈색 판 위에 올린다(배경 사진 위에서도 작은 글자가 읽히게) */
.host:is([data-phase='input'], [data-phase='reveal']) #view { padding: 22px 28px 26px; border-radius: 18px; background: rgba(58, 39, 24, .74); border: 1px solid var(--line); box-shadow: 0 18px 44px rgba(25, 14, 5, .45); min-height: calc(100vh - 140px); }
/* 배경 사진 위에 바로 놓이는 글자는 어두운 그림자로 받친다 */
.host #view { text-shadow: 0 2px 8px rgba(30, 18, 6, .9); }
.host #view :is(.chips, .board, .rules, .teams, button, table) { text-shadow: none; }
/* 순위표: 공용 화면에서는 두 단으로(13명째가 있으면 세 단) 흘려 한 화면에 담는다 */
.host ol.board { display: block; column-count: 2; column-gap: 16px; font-size: 26px; }
.host ol.board li { break-inside: avoid; margin-bottom: 8px; padding: 9px 18px; }
.host ol.board:has(li:nth-child(13)) { column-count: 3; font-size: 21px; }
.host ol.board:has(li:nth-child(13)) li { grid-template-columns: 44px 1fr auto; gap: 10px; padding: 7px 12px; margin-bottom: 6px; }
/* QR: 진행 중에는 오른쪽 아래 작은 명패, 입장 대기 때는 큰 명패 */
.host aside { position: fixed; right: 26px; bottom: 20px; z-index: 3; width: 128px; text-align: center; font-size: 13px; color: var(--soft); padding: 8px 8px 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.host aside img { width: 100%; display: block; background: #fff; border-radius: 6px; padding: 4px; }
.host aside p { margin: 4px 0 0; }
.host aside b { font-family: var(--f-latin); color: var(--gold); }
/* 입력·결과 공개·최종 순위 때는 QR 을 치운다(게임 화면을 가리지 않게). 규칙 설명과 순위표 때는 오른쪽에 자리를 비워 둔다 */
.host:is([data-phase='input'], [data-phase='reveal'], [data-phase='final']) aside { display: none; }
.host:is([data-phase='rules'], [data-phase='board']) main { padding-right: 150px; }
.url { word-break: break-all; color: var(--muted); font-size: 11px; display: none; }
/* 입장 대기 */
.host[data-phase='lobby'] { grid-template-columns: 340px 1fr; gap: 56px; padding: 200px 70px 40px; align-items: center; }
.host[data-phase='lobby']::before { height: 150px; }
.host[data-phase='lobby'] .brand { left: 50%; top: 14px; width: 460px; transform: translateX(-50%); }
.host[data-phase='lobby'] aside { position: static; width: auto; font-size: 20px; padding: 18px 18px 12px; border-radius: 14px; background: url(/theme/assets/marble-light.jpg) center / 420px; color: #3A2D1C; border: 0; box-shadow: inset 0 2px 0 #fff, inset 0 -3px 0 rgba(80, 60, 30, .3), 0 18px 44px rgba(60, 40, 15, .4), 0 0 0 1px var(--gold-deep); }
.host[data-phase='lobby'] aside img { border-radius: 8px; padding: 8px; box-shadow: inset 0 0 0 1px var(--gold-deep); }
.host[data-phase='lobby'] aside b { color: #7A5912; font-size: 1.3em; }
.host[data-phase='lobby'] .url { display: block; font-size: 15px; color: #6B5A40; }
.host[data-phase='lobby'] .stagebar { display: none; }
.host[data-phase='lobby'] h1 { font-size: 58px; margin-bottom: 18px; }
.host[data-phase='lobby'] main { padding: 26px 32px 30px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 18px 44px rgba(60, 40, 15, .3); }
/* 최종 순위: 월계관을 얹은 갈색 명판 */
.host[data-phase='final'] h1 { width: fit-content; margin: 0 auto 18px; padding: 66px 70px 14px; font-size: 54px; color: #FFE9A8; text-shadow: 0 2px 0 rgba(40, 24, 4, .9); border-radius: 14px; background: url(/theme/assets/laurel.jpg) center 4px / auto 70px no-repeat, var(--walnut); background-blend-mode: screen, normal; box-shadow: var(--shadow), inset 0 0 0 2px rgba(231, 200, 115, .7); }
.host[data-phase='final'] ol.board:first-of-type li:nth-child(1) { background: url(/theme/assets/marble-light.jpg) center / 420px; color: #33271A; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(231, 200, 115, .8), 0 12px 30px rgba(110, 80, 20, .4); font-size: 1.15em; }

/* ───────── 운영자 리모컨 ───────── */
.admin { background-image: linear-gradient(180deg, #4A3320, #33220F); padding-top: 14px; }
.admin h1 { font-size: 22px; color: var(--gold); margin: 6px 0 10px; }
.adminlist { list-style: none; padding: 0; display: grid; gap: 6px; }
.adminlist li { display: flex; gap: 6px; align-items: center; padding: 4px 4px 4px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line-2); }
.adminlist .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adminlist button { padding: 8px 12px; }

@media (prefers-reduced-motion: reduce) { button { transition: none; } }

.host[data-phase='final'] ol.board:first-of-type li:nth-child(1) :is(.rank, .score) { color: #7A5912; }
