/* ============================================================================
   Lucky台球 · 手机竖屏样式
   只能用 Chrome 61 支持的写法：
   - 不用 flex 的 gap（用 margin）、不用 inset 简写、不用 min / max / clamp 这三个函数、不用宽高比属性
   - 渐变的色标一个位置写一个，不写「颜色 0 2px」这种双位置写法
   - 用到 env() 的声明前面，先写一条不带 env() 的同名声明：
     不认识 env() 的浏览器会把那一条整条丢掉，留下前面这一条
   ============================================================================ */

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

html, body { height: 100%; }
html { touch-action: manipulation; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #f2f5f0;
  background: #06110b;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #06110b;
  background: radial-gradient(circle at 50% 36%, #0f2c1d 0%, #06110b 72%, #020503 100%);
}

/* ---------------------------------------------------------------- 屏幕 */
.screen {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
  /* 顶部要让开容器浮在页面上的返回、分享按钮。48px 是估计值，
     拿到 getWindowInfo 之后由 platform.js 写入 --bar-top，换成真实数值 */
  padding-top: 48px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 48px);
  padding-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.has-wininfo .screen { padding-top: var(--bar-top, 48px); }
.screen.is-active { display: flex; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-block;
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(212, 170, 74, 0.5);
  border-radius: 10px;
  background: #0d2418;
  background: linear-gradient(180deg, #123322 0%, #0a1f15 100%);
  color: #f2f5f0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}
.btn:active { opacity: 0.7; }
.btn[disabled] { opacity: 0.38; }
.btn--gold {
  border-color: #f7df94;
  background: #c89d42;
  background: linear-gradient(180deg, #f7df94 0%, #c89d42 100%);
  color: #1a1004;
  font-weight: 800;
}
.btn--plain { border-color: transparent; background: none; color: #9cb3a5; font-weight: 500; }
.btn--big { display: block; width: 100%; height: 52px; font-size: 17px; margin-top: 12px; }
.btn--block { display: block; width: 100%; margin-top: 10px; }

/* ---------------------------------------------------------------- 首页 */
.home {
  flex: 1 1 auto;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.home__ball {
  width: 92px; height: 92px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #16181c;
  background: radial-gradient(circle at 34% 30%, #6a6f78 0%, #16181c 46%, #050506 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.home__ball span {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fbf7ec;
  color: #121418;
  font-size: 26px;
  font-weight: 900;
  line-height: 40px;
}
.home__title { font-size: 34px; font-weight: 900; color: #f7df94; letter-spacing: 1px; }
.home__sub { margin-top: 4px; font-size: 15px; color: #c89d42; }
.home__rule { margin-top: 16px; font-size: 14px; color: #9cb3a5; }
.home__progress { margin-top: 18px; margin-bottom: 4px; font-size: 14px; color: #f2f5f0; }

/* ---------------------------------------------------------------- 顶栏 */
.bar {
  position: relative;
  flex: 0 0 auto;
  height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
}
.bar__btn {
  flex: 0 0 auto;
  height: 32px;
  min-width: 64px;
  padding: 0 10px;
  border: 1px solid rgba(212, 170, 74, 0.36);
  border-radius: 16px;
  background: rgba(10, 28, 19, 0.92);
  color: #f7df94;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.bar__btn:active { opacity: 0.7; }
.bar__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #f7df94;
}
.bar__right {
  flex: 0 0 auto;
  min-width: 64px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: #f2f5f0;
}
/* 对局顶栏中间放两行：上面是关卡名，下面是这一杆的目标 */
.bar__title--two { line-height: 1; }
.bar__title--two b, .bar__title--two small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar__title--two b { font-size: 14.5px; line-height: 20px; font-weight: 700; }
.bar__title--two small { font-size: 11px; line-height: 16px; font-weight: 400; color: #9cb3a5; }

/* ---------------------------------------------------------------- 关卡列表 */
.levels {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px 20px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-gap: 9px;
  align-content: start;
}
.lv {
  height: 64px;
  border: 1px solid rgba(212, 170, 74, 0.3);
  border-radius: 12px;
  background: rgba(10, 28, 19, 0.92);
  color: #f2f5f0;
  -webkit-appearance: none;
  appearance: none;
}
.lv:active { opacity: 0.7; }
.lv__num { display: block; font-size: 20px; font-weight: 800; line-height: 26px; }
.lv__stars { display: block; height: 16px; font-size: 11px; line-height: 16px; color: #5d7568; letter-spacing: 1px; }
.lv.is-done { border-color: #c89d42; }
.lv.is-done .lv__num { color: #f7df94; }
.lv.is-done .lv__stars { color: #ffd740; }
.lv.is-next { border-color: #18a062; box-shadow: 0 0 0 1px #18a062; }

/* ---------------------------------------------------------------- 球桌区 */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#tableCanvas {
  flex: 0 0 auto;
  display: block;
  margin: 0 -10px 0 0;   /* 右侧的力度条压住球桌木框外沿 10px，球桌可以画大一些；和 game.js 的 SIDE_OVERLAP 一致 */
  touch-action: none;
}
.side {
  position: relative;
  z-index: 2;
  flex: 0 0 40px;
  width: 40px;
  height: 68%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.side__label {
  flex: 0 0 auto;
  height: 34px;
  font-size: 10.5px;
  line-height: 15px;
  text-align: center;
  color: #9cb3a5;
}
.side__label b { color: #f7df94; font-size: 11.5px; }
.power {
  flex: 1 1 auto;
  width: 30px;
  border: 1px solid rgba(212, 170, 74, 0.45);
  border-radius: 15px;
  background-color: #0a1c13;
  touch-action: none;
  position: relative;
  overflow: hidden;
}
.power__fill {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 0;
  background: #ffd740;
  opacity: 0.55;
}
/* 金色横线：上一杆（或推荐杆法）的力度，往下拉到这附近会吸住 */
.power__mark {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 3px;
  margin-top: -1.5px;
  background: #f7df94;
  box-shadow: 0 0 4px rgba(247, 223, 148, 0.9);
}
.power__thumb {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 10px;
  margin-top: -5px;
  background: #ffffff;
  border-radius: 5px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}
.power__hint {
  position: absolute;
  left: 0; right: 0; bottom: 12px;
  font-size: 11px;
  line-height: 30px;
  color: #6f8a7b;
  text-align: center;
  -webkit-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
  letter-spacing: 3px;
  pointer-events: none;
}
.power.is-pulling { border-color: #f7df94; }
.power.is-pulling .power__hint { display: none; }

.toast {
  position: absolute;
  left: 82px; right: 72px; top: 0; bottom: 0;   /* 正好盖住顶栏中间的关卡名，让开两边的返回按钮和杆数 */
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(110, 255, 185, 0.5);
  border-radius: 10px;
  background: #04100a;
  color: #d6f7e6;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.toast.is-show { opacity: 1; }
.toast--gold { border-color: rgba(255, 215, 64, 0.7); color: #ffe9a6; }
.toast--warn { border-color: rgba(255, 110, 110, 0.7); color: #ffc9c9; }

/* ---------------------------------------------------------------- 底部操作条 */
.dock {
  flex: 0 0 auto;
  height: 68px;
  padding: 6px 10px 8px;
  display: flex;
  align-items: center;
}
.spinbtn {
  flex: 0 0 auto;
  width: 50px;
  height: 54px;
  border: 0;
  background: none;
  color: #9cb3a5;
  font-size: 10.5px;
  line-height: 12px;
  -webkit-appearance: none;
  appearance: none;
}
.spinbtn canvas { display: block; width: 40px; height: 40px; margin: 0 auto 2px; }
.spinbtn:active { opacity: 0.7; }
.dock__btn { flex: 1 1 0; min-width: 0; padding: 0; margin-left: 6px; font-size: 14px; }
.dock__nudge { flex: 0 0 46px; width: 46px; padding: 0; margin-left: 6px; font-size: 22px; line-height: 1; touch-action: none; }
.is-moving .dock, .is-moving .side { opacity: 0.45; pointer-events: none; }

/* ---------------------------------------------------------------- 弹层 */
.overlay {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 340px;
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
  border: 1px solid rgba(212, 170, 74, 0.45);
  border-radius: 16px;
  background: #0b2014;
}
.sheet--center { text-align: center; }
.sheet__title { font-size: 18px; font-weight: 800; color: #f7df94; }
.sheet__meta { margin-top: 2px; font-size: 12.5px; color: #c89d42; }
.sheet__text { margin-top: 10px; font-size: 14px; color: #d6e8dd; text-align: left; }
.sheet--center .sheet__text { text-align: center; }
.sheet__note { margin-top: 6px; font-size: 12px; color: #9cb3a5; text-align: center; }
.sheet__readout { margin-top: 8px; font-size: 14px; font-weight: 700; color: #f7df94; text-align: center; }
.sheet__row { display: flex; margin-top: 12px; }
.sheet__row .btn { flex: 1 1 0; min-width: 0; padding: 0; }
.sheet__row .btn + .btn { margin-left: 10px; }
#spinPad { display: block; width: 220px; height: 220px; margin: 12px auto 0; touch-action: none; }
.stars { margin-top: 6px; font-size: 30px; line-height: 38px; color: #ffd740; letter-spacing: 4px; }
.help { margin-top: 10px; padding-left: 18px; font-size: 13.5px; color: #d6e8dd; }
.help li { margin-top: 7px; }
.help b { color: #f7df94; }
