/* ——— Wine World Journey UI ——— */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --gold: #e8c26a;
  --wine: #8e2043;
  --ink: #1a1014;
  --panel-bg: rgba(20, 12, 16, 0.92);
  --footer-h: 10vh;          /* statutory warning bar: 1/10 of the screen */
  --serif: "Palatino", "Songti TC", Georgia, serif;
  --sans: "Avenir Next", "PingFang TC", "Hiragino Sans", "Apple SD Gothic Neo", "Helvetica Neue", sans-serif;
}
html, body { width: 100%; height: 100%; overflow: hidden; background: #120a0e; font-family: var(--sans); }
#renderCanvas { width: 100%; height: calc(100% - var(--footer-h)); display: block; outline: none; touch-action: none; }

/* ——— Loading / Title screen ——— */
#titleScreen {
  position: fixed; top: 0; left: 0; right: 0; bottom: var(--footer-h); z-index: 60; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(ellipse at 50% 35%, #3d1626 0%, #1c0d14 55%, #0c060a 100%);
  transition: opacity 1.2s ease; color: #f4e9d8;
}
#titleScreen.hidden { opacity: 0; pointer-events: none; }
#titleScreen .glass { font-size: 64px; margin-bottom: 8px; filter: drop-shadow(0 6px 24px rgba(232,194,106,.35)); }
#titleScreen h1 { font-family: var(--serif); font-size: clamp(34px, 6vw, 64px); letter-spacing: .06em; color: var(--gold); font-weight: 600; }
#titleScreen h2 { font-family: var(--serif); font-size: clamp(18px, 3vw, 28px); margin-top: 6px; font-weight: 400; opacity: .85; }
#titleScreen p.sub { margin-top: 18px; max-width: 560px; line-height: 1.7; opacity: .68; font-size: 15px; padding: 0 24px; }
#startBtn {
  margin-top: 34px; padding: 14px 52px; font-size: 18px; letter-spacing: .12em;
  font-family: var(--sans); color: #241018; background: linear-gradient(180deg, #f0cf85, #d9a13b);
  border: none; border-radius: 40px; cursor: pointer; transition: transform .2s, box-shadow .2s;
  box-shadow: 0 8px 30px rgba(217,161,59,.35);
}
#startBtn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 40px rgba(217,161,59,.5); }
#startBtn:disabled { opacity: .45; cursor: wait; transform: none; }
#loadNote { margin-top: 16px; font-size: 13px; opacity: .5; }

/* ——— HUD ——— */
.hud { position: fixed; z-index: 30; color: #f4e9d8; user-select: none; }
#topBar { top: 16px; right: 16px; display: flex; gap: 10px; align-items: center; }
.hudBtn {
  padding: 8px 16px; border-radius: 24px; border: 1px solid rgba(232,194,106,.5);
  background: rgba(20,12,16,.66); color: var(--gold); font-size: 14px; cursor: pointer;
  backdrop-filter: blur(6px); transition: background .2s;
  font-family: var(--sans);
}
.hudBtn:hover { background: rgba(80,32,48,.8); }
#brand { top: 16px; left: 18px; font-family: var(--serif); font-size: 17px; letter-spacing: .1em; color: var(--gold); opacity: .9; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#brand small { display: block; font-size: 11px; letter-spacing: .28em; opacity: .75; color: #f4e9d8; }
#progress { bottom: calc(var(--footer-h) + 18px); right: 18px; font-size: 14px; background: rgba(20,12,16,.66); padding: 8px 16px; border-radius: 20px; border: 1px solid rgba(232,194,106,.35); backdrop-filter: blur(6px); }
#hint { bottom: calc(var(--footer-h) + 18px); left: 18px; font-size: 12.5px; opacity: .75; line-height: 1.6; text-shadow: 0 1px 4px #000; max-width: 320px; }

/* ——— Fast travel dots ——— */
#travelBar {
  bottom: calc(var(--footer-h) + 64px); left: 50%; transform: translateX(-50%); display: flex; gap: 8px;
  background: rgba(20,12,16,.6); padding: 8px 14px; border-radius: 26px;
  border: 1px solid rgba(232,194,106,.3); backdrop-filter: blur(6px);
}
.travelDot { font-size: 20px; cursor: pointer; opacity: .55; transition: all .2s; position: relative; line-height: 1; }
.travelDot:hover { opacity: 1; transform: scale(1.25); }
.travelDot.active { opacity: 1; transform: scale(1.15); }
.travelDot .tip {
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 12px; background: rgba(20,12,16,.9); color: var(--gold); padding: 4px 10px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.travelDot:hover .tip { opacity: 1; }

/* ——— Country banner toast ——— */
#banner {
  top: 12%; left: 50%; transform: translate(-50%, -8px); text-align: center;
  opacity: 0; transition: opacity .8s ease, transform .8s ease; pointer-events: none;
}
#banner.show { opacity: 1; transform: translate(-50%, 0); }
#banner .b1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 52px); color: var(--gold); letter-spacing: .12em; text-shadow: 0 4px 24px rgba(0,0,0,.7); }
#banner .b2 { font-family: var(--serif); font-size: clamp(16px, 2.4vw, 24px); color: #f4e9d8; opacity: .9; margin-top: 2px; letter-spacing: .3em; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
#banner .rule { width: 130px; height: 1px; margin: 10px auto 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

/* ——— Interact prompt ——— */
#prompt {
  bottom: calc(var(--footer-h) + 120px); left: 50%; transform: translateX(-50%); cursor: pointer;
  background: rgba(20,12,16,.82); border: 1px solid rgba(232,194,106,.55); color: #f4e9d8;
  padding: 10px 22px; border-radius: 30px; font-size: 15px; backdrop-filter: blur(8px);
  display: none; align-items: center; gap: 10px; box-shadow: 0 6px 30px rgba(0,0,0,.45);
  animation: bob 1.6s ease-in-out infinite;
}
#prompt.show { display: flex; }
#prompt .key { background: var(--gold); color: #241018; font-weight: 700; border-radius: 8px; padding: 2px 9px; font-size: 13px; }
@keyframes bob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }

/* ——— Region panel ——— */
#panel {
  position: fixed; top: 0; right: 0; bottom: var(--footer-h); width: min(480px, 94vw); z-index: 40;
  background: var(--panel-bg); backdrop-filter: blur(14px);
  border-left: 1px solid rgba(232,194,106,.35);
  transform: translateX(105%); transition: transform .45s cubic-bezier(.22,.9,.3,1);
  color: #f4e9d8; display: flex; flex-direction: column;
}
#panel.open { transform: translateX(0); }
#panelClose {
  position: absolute; top: 14px; right: 16px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid rgba(232,194,106,.5); background: transparent; color: var(--gold);
  font-size: 18px; cursor: pointer; z-index: 2;
}
#panelClose:hover { background: rgba(142,32,67,.5); }
#panelScroll { overflow-y: auto; padding: 30px 30px 40px; scrollbar-width: thin; scrollbar-color: rgba(232,194,106,.4) transparent; }
#panelScroll .kicker { font-size: 11px; letter-spacing: .3em; color: var(--gold); opacity: .85; }
#panelScroll h2 { font-family: var(--serif); font-size: 34px; margin-top: 6px; color: #fff; line-height: 1.15; }
#panelScroll h3.zh { font-family: var(--serif); font-size: 20px; color: var(--gold); margin-top: 2px; font-weight: 500; }
#panelScroll .style { margin-top: 14px; font-style: italic; font-family: var(--serif); font-size: 15.5px; line-height: 1.65; color: #f0d9a8; border-left: 2px solid var(--gold); padding-left: 12px; }
#panelScroll .factsTitle, #panelScroll .winesTitle { margin-top: 26px; font-size: 11px; letter-spacing: .3em; color: var(--gold); }
#panelScroll ol.facts { margin: 12px 0 0 0; list-style: none; counter-reset: f; }
#panelScroll ol.facts li {
  counter-increment: f; position: relative; padding: 0 0 14px 40px; font-size: 14px; line-height: 1.75; opacity: .92;
}
#panelScroll ol.facts li::before {
  content: "0" counter(f); position: absolute; left: 0; top: 2px; font-family: var(--serif);
  color: var(--gold); font-size: 17px; opacity: .9;
}
.wineCard {
  display: block; margin-top: 12px; padding: 14px 16px; border: 1px solid rgba(232,194,106,.25);
  border-radius: 12px; background: rgba(255,255,255,.04); text-decoration: none; color: inherit;
  transition: border-color .2s, background .2s, transform .2s;
}
.wineCard:hover { border-color: var(--gold); background: rgba(142,32,67,.25); transform: translateX(-3px); }
.wineCard .p { font-size: 15px; font-weight: 600; color: #fff; }
.wineCard .w { font-family: var(--serif); font-size: 14px; color: var(--gold); margin-top: 2px; }
.wineCard .g { font-size: 12px; opacity: .65; margin-top: 4px; }
.wineCard .more { float: right; font-size: 12px; color: var(--gold); opacity: .8; }
#panelScroll .pageLink { display: inline-block; margin-top: 24px; color: var(--gold); font-size: 14px; text-decoration: none; border-bottom: 1px solid rgba(232,194,106,.5); padding-bottom: 2px; }
#panelScroll .pageLink:hover { border-bottom-color: var(--gold); }

/* ——— fade overlay for teleports ——— */
#fade { position: fixed; top: 0; left: 0; right: 0; bottom: var(--footer-h); background: #0c060a; opacity: 0; pointer-events: none; transition: opacity .5s ease; z-index: 50; }
#fade.dark { opacity: 1; }

@media (max-width: 700px) {
  #hint { display: none; }
  #travelBar { bottom: calc(var(--footer-h) + 16px); }
  #progress { bottom: calc(var(--footer-h) + 70px); }
}

/* ——— HUD score chip ——— */
.hudChip {
  padding: 8px 16px; border-radius: 24px; border: 1px solid rgba(232,194,106,.5);
  background: rgba(20,12,16,.66); color: var(--gold); font-size: 14px; font-weight: 600;
  backdrop-filter: blur(6px);
}
.hudChip .bump { animation: scoreBump .5s ease; display: inline-block; }
@keyframes scoreBump { 0% { transform: scale(1); } 40% { transform: scale(1.5); color: #fff; } 100% { transform: scale(1); } }

/* ——— Modals (quiz / leaderboard) ——— */
.modalWrap {
  position: fixed; top: 0; left: 0; right: 0; bottom: var(--footer-h); z-index: 55; display: none; align-items: center; justify-content: center;
  background: rgba(10,5,8,.6); backdrop-filter: blur(4px);
}
.modalWrap.open { display: flex; }
.modalCard {
  position: relative; width: min(560px, 92vw); max-height: 78vh; overflow-y: auto;
  background: var(--panel-bg); border: 1px solid rgba(232,194,106,.4); border-radius: 18px;
  padding: 30px 34px; color: #f4e9d8; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modalClose {
  position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(232,194,106,.5); background: transparent; color: var(--gold); font-size: 16px; cursor: pointer;
}
.modalClose:hover { background: rgba(142,32,67,.5); }
.qKicker { font-size: 12px; letter-spacing: .28em; color: var(--gold); }
.qDots { display: flex; gap: 8px; margin: 14px 0 4px; }
.qDots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(232,194,106,.25); }
.qDots span.on { background: var(--gold); }
.qDots span.good { background: #6fae5a; }
.qDots span.bad { background: #c34a4a; }
.qQuestion { font-family: var(--serif); font-size: 21px; line-height: 1.5; margin: 14px 0 18px; color: #fff; }
.qOpts { display: flex; flex-direction: column; gap: 10px; }
.qOpt {
  text-align: left; padding: 13px 16px; border-radius: 12px; border: 1px solid rgba(232,194,106,.3);
  background: rgba(255,255,255,.045); color: #f4e9d8; font-size: 14.5px; line-height: 1.5; cursor: pointer;
  transition: all .15s; font-family: var(--sans);
}
.qOpt:hover { border-color: var(--gold); background: rgba(142,32,67,.3); }
.qOpt.good { border-color: #6fae5a; background: rgba(111,174,90,.25); }
.qOpt.bad { border-color: #c34a4a; background: rgba(195,74,74,.25); }
.qOpt:disabled { cursor: default; opacity: .85; }
.qResult { margin-top: 16px; font-family: var(--serif); font-size: 19px; color: var(--gold); min-height: 26px; }

/* ——— Leaderboard ——— */
.nameRow { display: flex; gap: 10px; margin: 16px 0 18px; }
#nameInput {
  flex: 1; padding: 10px 14px; border-radius: 12px; border: 1px solid rgba(232,194,106,.4);
  background: rgba(255,255,255,.06); color: #fff; font-size: 15px; outline: none; font-family: var(--sans);
}
#nameInput:focus { border-color: var(--gold); }
.boardRow {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px;
}
.boardRow.me { background: rgba(142,32,67,.35); border: 1px solid rgba(232,194,106,.4); }
.boardRow .rk { width: 30px; color: var(--gold); font-family: var(--serif); font-size: 16px; }
.boardRow .nm { flex: 1; font-weight: 600; }
.boardRow .sc { color: var(--gold); font-weight: 700; }
.boardRow .sub2 { font-size: 11.5px; opacity: .6; }
.boardEmpty { opacity: .6; font-size: 14px; padding: 12px; }

/* ——— Minimap ——— */
#minimap {
  bottom: calc(var(--footer-h) + 64px); right: 18px; border-radius: 16px;
  border: 1px solid rgba(232,194,106,.35); background: rgba(20,12,16,.62);
  backdrop-filter: blur(8px); padding: 8px; display: none;
}
#minimap.show { display: block; }
#mmTitle { font-size: 12px; color: var(--gold); letter-spacing: .06em; padding: 2px 4px 7px; display: flex; justify-content: space-between; gap: 12px; }
#mmCanvas { width: 230px; height: 230px; display: block; cursor: pointer; border-radius: 10px; }
@media (max-width: 700px) { #minimap { display: none !important; } }

/* ——— NPC dialog (speech bubble) ——— */
#npcDialog {
  bottom: calc(var(--footer-h) + 128px); left: 50%; transform: translateX(-50%) translateY(12px);
  width: min(560px, 92vw); background: var(--panel-bg); backdrop-filter: blur(10px);
  border: 1px solid rgba(232,194,106,.5); border-radius: 18px; padding: 16px 18px 14px;
  opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s ease;
  box-shadow: 0 14px 50px rgba(0,0,0,.5);
}
#npcDialog.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
#npcDialog .npcArrow {
  position: absolute; left: 50%; bottom: -9px; width: 16px; height: 16px;
  transform: translateX(-50%) rotate(45deg); background: rgba(20,12,16,.92);
  border-right: 1px solid rgba(232,194,106,.5); border-bottom: 1px solid rgba(232,194,106,.5);
}
#npcClose {
  position: absolute; top: 10px; right: 12px; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid rgba(232,194,106,.4); background: transparent; color: var(--gold);
  font-size: 13px; cursor: pointer;
}
#npcDialog .npcHead { display: flex; gap: 12px; align-items: center; padding-right: 30px; }
#npcDialog .npcAvatar { font-size: 34px; filter: drop-shadow(0 3px 8px rgba(0,0,0,.5)); animation: npcBob 1.4s ease-in-out infinite; }
@keyframes npcBob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-5px) rotate(4deg); } }
#npcName { font-family: var(--serif); font-size: 17px; color: var(--gold); }
#npcGreet { font-size: 14px; color: #f4e9d8; opacity: .92; margin-top: 2px; }
#npcDialog .npcBtns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.npcBtn {
  flex: 1; min-width: 140px; padding: 10px 12px; border-radius: 12px; font-size: 13.5px;
  border: 1px solid rgba(232,194,106,.35); background: rgba(255,255,255,.05);
  color: #f4e9d8; cursor: pointer; transition: all .15s; font-family: var(--sans);
}
.npcBtn:hover { border-color: var(--gold); background: rgba(142,32,67,.35); transform: translateY(-1px); }

/* ——— Arcade overlay ——— */
.arcadeCard { width: min(460px, 94vw); padding: 18px 16px 14px; }
#arcadeFrameWrap {
  position: relative; margin-top: 12px; width: 100%; height: min(66vh, 760px);
  border-radius: 12px; overflow: hidden; background: #120a0e; border: 1px solid rgba(232,194,106,.25);
}
#arcadeFrame { width: 100%; height: 100%; border: 0; display: block; }
#arcadeSpin {
  position: absolute; inset: 0; display: none; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: #120a0e; z-index: 2;
  color: var(--gold); font-size: 14px;
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(232,194,106,.25); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— 台灣法定飲酒警語 (Taiwan statutory drinking warning) ———
   Always visible, never covered by the game, the panels or the modals. */
#warnFooter {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  height: var(--footer-h); min-height: 48px;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(10px, 3vw, 44px); flex-wrap: wrap;
  padding: 4px 16px; box-sizing: border-box;
  background: linear-gradient(180deg, #2b1119 0%, #150a0f 100%);
  border-top: 2px solid var(--gold);
  box-shadow: 0 -6px 24px rgba(0,0,0,.55);
  user-select: none; pointer-events: none;
}
#warnFooter .warn {
  color: #ffe9bd; font-family: var(--sans); font-weight: 700;
  font-size: clamp(13px, 2.3vh, 24px); letter-spacing: .1em; line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); white-space: nowrap;
}
#warnFooter .warnSep { color: var(--gold); opacity: .8; font-size: clamp(13px, 2vh, 22px); }
@media (max-width: 620px) {
  #warnFooter { gap: 2px; }
  #warnFooter .warnSep { display: none; }
  #warnFooter .warn { font-size: clamp(12px, 1.9vh, 16px); letter-spacing: .05em; }
}

/* ——— Exit back to the main site ——— */
#exitBtn {
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  border-color: rgba(232,194,106,.35); color: #f4e9d8; opacity: .9;
}
#exitBtn:hover { background: rgba(142,32,67,.75); border-color: var(--gold); opacity: 1; }
