/* 글자 크기는 --ui 하나로 전부 따라간다 (1rem = 16px × --ui) */
:root { --ui: 1.3; }
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--ui)); }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c3a2b; color: #eef1f7;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
#table { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

/* 굴림 결과 팝업: 잠깐 떴다가 사라진다. 클릭을 막지 않는다 */
#result { position: fixed; left: 50%; top: 42%; z-index: 18; pointer-events: none; transform: translate(-50%, -50%);
  min-width: 18rem; padding: 0.9rem 2rem 1rem; border-radius: 16px; text-align: center;
  box-shadow: 0 10px 40px rgb(0 0 0 / 55%); border: 3px solid transparent; }
#result[hidden] { display: none; }
#result.win { background: rgb(22 84 48 / 95%); border-color: #6fe39a; }
#result.lose { background: rgb(96 28 32 / 95%); border-color: #ff8f8f; }
#result.show { animation: rpop 0.22s ease-out both; }
#result.hide { animation: rfade 0.3s ease-in both; }
#result .rbig { font-size: 2.6rem; font-weight: 900; line-height: 1.15; }
#result.win .rbig { color: #d9ffe6; }
#result.lose .rbig { color: #ffe0e0; }
#result .rline { font-size: 1.05rem; font-weight: bold; margin-top: 0.3rem; color: #fff; }
#result .rsub { font-size: 0.85rem; margin-top: 0.25rem; color: #ffe08a; }
#result .rsub:empty { display: none; }
@keyframes rpop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes rfade { from { opacity: 1; } to { opacity: 0; transform: translate(-50%, -60%) scale(0.95); } }
.tlabel { position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-size: 0.8rem; font-weight: bold; color: #cfe3d6; text-shadow: 0 1px 2px #000a; }
.tlabel.big { font-size: 0.95rem; color: #fff; }
.tlabel.small { font-size: 0.72rem; }
.tlabel.warn { color: #ffd76a; }
.tlabel.hint { color: #9fc4ad; font-size: 0.9rem; }
.tlabel.marks { font-size: 1.05rem; color: #fff; background: rgb(0 0 0 / 30%); padding: 2px 12px; border-radius: 14px; }

#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0.8rem;
  background: rgb(0 0 0 / 30%); font-size: 0.8rem; }
#topbar b { font-size: 0.95rem; color: #ffd76a; white-space: nowrap; }
#topbar #status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#topbar .sp { flex: 1; }
#topbar button, #rulesClose, #logClose { background: #2f3646; color: #eef1f7; border: 1px solid #505a70;
  border-radius: 6px; padding: 0.2rem 0.6rem; cursor: pointer; font: inherit; white-space: nowrap; }
#topbar button:hover { filter: brightness(1.2); }
#topbar button.on { background: #1f5a52; border-color: #3fae9d; }
.fontctl { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.fontctl #fontPct { min-width: 3em; text-align: center; color: #cfe3d6; }

#bar { position: fixed; left: 0; right: 0; bottom: 0; height: 12rem; z-index: 10;
  display: grid; grid-template-columns: 1fr auto; gap: 0.8rem; padding: 0.5rem 0.8rem;
  background: rgb(16 22 30 / 92%); border-top: 1px solid #ffffff22; }
#bar[hidden] { display: none; }
#left { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; min-height: 0; }
#msg .prompt { font-size: 0.95rem; font-weight: bold; color: #ffe08a; }
#msg .story { font-size: 0.9rem; color: #f3ecdc; margin-top: 2px; line-height: 1.4; }
#msg .last { font-size: 0.72rem; color: #aab5c3; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#actions { display: flex; flex-wrap: wrap; gap: 0.45rem; overflow-y: auto; align-content: flex-start; min-height: 0; flex: 1; }

/* 주사위 인벤토리 */
#inv { width: min(24rem, 42vw); display: flex; flex-direction: column; gap: 0.3rem; min-height: 0;
  background: rgb(0 0 0 / 28%); border: 1px solid #ffffff1a; border-radius: 10px; padding: 0.4rem 0.6rem; overflow-y: auto; }
#inv[hidden] { display: none; }
.invhead { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.8rem; }
.invhead b { color: #ffe08a; margin-right: auto; }
.invtabs { display: flex; gap: 3px; flex-wrap: wrap; }
.invtabs .tab { font: inherit; font-size: 0.65rem; padding: 1px 6px; border-radius: 5px; cursor: pointer;
  background: #2f3646; color: #cfd6e0; border: 1px solid #505a70; }
.invtabs .tab.on { background: #d9a52b; color: #231a00; border-color: #f3c95a; }
.dice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem; }
.die { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 0.25rem 0.1rem; border-radius: 8px;
  background: #262c3a; border: 2px solid #3d4659; color: #eef1f7; cursor: pointer; font: inherit; }
.die:hover { filter: brightness(1.2); }
.die .face { width: 3rem; height: 3rem; }
.die .face.rolling { transform: rotate(-8deg); }
.diesvg { width: 100%; height: 100%; display: block; }
.die .dname { font-size: 0.68rem; font-weight: bold; white-space: nowrap; }
.die .dstate { font-size: 0.62rem; color: #8fd7a8; }
.die .dstate.c { color: #ffb36b; }
.die.cool { opacity: 0.55; border-style: dashed; }
.die.want { opacity: 1; border-color: #ffd23f; box-shadow: 0 0 0 3px #ffd23f55; animation: pulse 0.9s infinite alternate; }
.die.want .dstate { color: #ffe08a; font-weight: bold; }
@keyframes pulse { from { box-shadow: 0 0 0 2px #ffd23f44; } to { box-shadow: 0 0 0 6px #ffd23f88; } }
.invnote { font-size: 0.6rem; color: #9aa6b6; line-height: 1.35; }
.abil { display: flex; flex-direction: column; gap: 2px; font-size: 0.68rem; }
.abil .ab { display: flex; justify-content: space-between; gap: 0.5rem; background: #1f5a5244; border-radius: 5px; padding: 1px 6px; }
.abil .ab span { color: #e0a800; letter-spacing: 1px; }

/* 기록 서랍 */
#logPanel { position: fixed; right: 0.6rem; top: 3rem; bottom: 12.6rem; width: min(26rem, 90vw); z-index: 15;
  display: flex; flex-direction: column; background: rgb(16 22 30 / 96%); border: 1px solid #ffffff22; border-radius: 10px; padding: 0.5rem 0.7rem; }
#logPanel[hidden] { display: none; }
.loghead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
#logList { overflow-y: auto; font-size: 0.75rem; line-height: 1.5; color: #c3ccd8; }
#logList div { border-bottom: 1px dashed #ffffff14; padding: 2px 0; }

button.act { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 7rem; max-width: 22rem; padding: 0.35rem 0.7rem; border-radius: 8px; cursor: pointer;
  background: #2f3646; color: #eef1f7; border: 1px solid #58627a; font: inherit; text-align: left; }
button.act:hover:not(:disabled) { filter: brightness(1.18); }
button.act:disabled { opacity: 0.45; cursor: not-allowed; }
button.act .lbl { font-size: 0.88rem; font-weight: bold; }
button.act .sub { font-size: 0.7rem; color: #b8c2d0; white-space: pre-line; line-height: 1.35; }
button.act.primary { background: #d9a52b; color: #231a00; border-color: #f3c95a; }
button.act.primary .sub { color: #4a3800; }
button.act.choice { background: #3d3170; border-color: #7a67cf; }
button.act.tired { border-style: dashed; border-color: #ffb36b; }
button.act.mark { background: #6b4f16; border-color: #d9a52b; }
button.act.coop { background: #1d4f7a; border-color: #5aa7e8; }
button.act.ability { background: #1f5a52; border-color: #3fae9d; }
button.act.danger { background: #5a2a2a; border-color: #b0544f; }
button.act.ghost { background: transparent; }
button.act.count { min-width: 5rem; align-items: center; }
button.act.big { padding: 0.55rem 1rem; }
button.act.big .lbl { font-size: 1rem; }

.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgb(0 0 0 / 60%); }
.overlay[hidden] { display: none; }
#rules { z-index: 25; }
.panel { max-width: min(46rem, 94vw); max-height: 88vh; overflow-y: auto; padding: 1.1rem 1.5rem; border-radius: 12px;
  background: #232733; color: #eef1f7; line-height: 1.6; font-size: 0.95rem; }
.panel h3 { margin: 0.9rem 0 0.25rem; color: #ffd76a; }
.panel ol { margin: 0; padding-left: 1.4rem; }
.lobby { text-align: center; }
.lobby h1 { margin: 0; color: #ffd76a; font-size: 1.6rem; }
.lobby p { margin: 0.4rem 0; }
.tagline { color: #c9b3ff; margin-top: 0; }
.toggle { display: block; margin: 0.6rem auto; max-width: 36rem; cursor: pointer; }
.toggle input { transform: scale(1.3); margin-right: 6px; }
.counts { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; margin: 0.6rem 0; }
.seats { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; margin: 0.5rem 0; }
.seat { display: flex; flex-direction: column; align-items: center; min-width: 4.2rem; padding: 0.3rem 0.5rem; border-radius: 8px;
  background: #1b1f29; border: 1px dashed #505a70; color: #8f99aa; font: inherit; font-size: 0.8rem; }
button.seat { cursor: pointer; }
.seat.in { background: #2f3646; color: #eef1f7; border-style: solid; }
.seat.human { background: #1f5a52; border-color: #3fae9d; }
.linkrow { display: flex; gap: 0.4rem; justify-content: center; align-items: center; }
.link { flex: 1; min-width: 0; font: inherit; font-size: 0.75rem; padding: 0.35rem 0.5rem; border-radius: 6px; border: 1px solid #505a70; background: #151922; color: #cfe3d6; }
.err { text-align: left; white-space: pre-wrap; font-size: 0.75rem; background: #151922; padding: 0.5rem; border-radius: 6px; }
.warn { color: #ffd76a; }
.lose { color: #ff8f8f; }
.endp { text-align: center; min-width: min(24rem, 90vw); }
.endp h2.win { color: #ffd76a; font-size: 1.9rem; }
.endp h2.lose { color: #ff8f8f; font-size: 1.9rem; }
.dim { color: #aeb8c6; }
.row { display: flex; gap: 0.6rem; justify-content: center; margin-top: 0.75rem; flex-wrap: wrap; }
