/* =========================================================================
 * 黄金矿工 · 双人版 —— 样式（暖色调柔和卡通风格）
 * 适配重点：iPad 横屏触控（大按钮、禁缩放、安全区铺满）
 * ========================================================================= */

:root {
  --warm-bg: #fff3e0;       /* 暖米色背景 */
  --warm-bg2: #ffe0b2;      /* 次暖色 */
  --accent: #ff8c42;        /* 主暖橙 */
  --accent2: #ff6f91;       /* 爱心粉 */
  --ink: #5a4632;           /* 深棕文字 */
  --ink-soft: #8a7355;
  --card: #fffaf2;
  --shadow: 0 8px 24px rgba(180, 120, 60, 0.18);
  --green: #4a8f3c;         /* 目标/当前分（对齐参考版的绿色） */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--warm-bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}

#app { width: 100%; height: 100%; position: relative; }

/* ---------------- 屏幕切换 ---------------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

/* ---------------- 首页 ---------------- */
#screen-home { background: linear-gradient(160deg, #fff3e0 0%, #ffe0b2 60%, #ffd0a0 100%); }
.home-card {
  width: min(86vw, 460px);
  background: var(--card);
  border-radius: 28px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.title { font-size: 34px; margin: 0 0 6px; color: var(--accent); letter-spacing: 2px; }
.title .sub { display: block; font-size: 15px; color: var(--ink-soft); margin-top: 6px; letter-spacing: 4px; }
.slogan { color: var(--ink-soft); font-size: 14px; margin: 0 0 22px; }

.field { display: block; text-align: left; margin-bottom: 18px; font-size: 13px; color: var(--ink-soft); }
.field input, .join-row input, #code-input {
  width: 100%; margin-top: 6px; padding: 14px 14px;
  font-size: 17px; border: 2px solid #ffd9b0; border-radius: 14px;
  background: #fff; color: var(--ink); outline: none;
}
.join-row { display: flex; gap: 10px; margin-bottom: 12px; }
.join-row input { flex: 1; text-align: center; letter-spacing: 6px; font-weight: 700; }

.btn {
  border: none; border-radius: 16px; cursor: pointer;
  font-size: 18px; font-weight: 700; padding: 15px 18px;
  transition: transform .08s ease, filter .15s ease;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(255,140,66,.4); }
.btn-secondary { background: #ffd9b0; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 2px solid #ffd9b0; }
.btn-primary.hidden, .hidden { display: none !important; }

.hint { min-height: 18px; color: var(--accent2); font-size: 14px; margin: 10px 0 0; }

/* ---------------- 游戏主界面 ---------------- */
#screen-game { background: #2a1c10; }
#game-canvas {
  display: block;
  width: 100%; height: 100%;
  touch-action: none; /* 防止画布上滑动触发页面滚动 */
}

/* 顶部 HUD：左「目标/当前」 中「房间」 右「时间/关卡」 */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(0,0,0,.42), rgba(0,0,0,0));
  color: #fff; z-index: 5; pointer-events: none;
}
.hud-side { display: flex; flex-direction: column; gap: 6px; }
.hud-right { align-items: flex-end; }
.hud-row {
  display: flex; align-items: baseline; gap: 8px;
  background: rgba(255,255,255,.14); padding: 5px 12px; border-radius: 12px;
  backdrop-filter: blur(4px);
}
.hud-k { font-size: 14px; opacity: .95; }
.hud-v { font-size: 21px; font-weight: 800; color: #ffd54f; letter-spacing: 1px; }
.hud-cur { color: var(--green); text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.hud-time { color: #ffd54f; }
.hud-time.urgent { color: #ff5252; animation: blink .8s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.hud-mid {
  align-self: center;
  background: rgba(255,255,255,.12); padding: 5px 12px; border-radius: 12px;
  font-size: 13px; opacity: .9;
}
.hud-mid b { letter-spacing: 2px; color: #fff; }

/* 右上角暂停 / 继续按钮 */
.pause-btn {
  position: absolute; top: 64px; right: 12px; z-index: 30;
  width: 50px; height: 50px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.45); color: #fff;
  font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); box-shadow: 0 4px 12px rgba(0,0,0,.3);
  transition: transform .08s ease, background .15s ease;
}
.pause-btn:active { transform: scale(0.92); background: rgba(0,0,0,.6); }

/* 关卡开始卡片（云朵） */
#level-intro {
  position: absolute; inset: 0; z-index: 12;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.cloud-card {
  background: var(--card);
  border: 5px solid #fff;
  border-radius: 64px 64px 52px 52px;
  padding: 26px 54px;
  text-align: center;
  box-shadow: 0 14px 34px rgba(120, 70, 20, .32);
}
.li-title { font-size: 25px; font-weight: 800; color: var(--green); }
.li-title b { font-size: 30px; }
.li-target { font-size: 23px; font-weight: 800; color: #3f8a34; margin-top: 8px; }
.li-target b { font-size: 27px; }
.li-tip { font-size: 12px; color: #b3a28d; margin-top: 12px; }
#level-intro.pop .cloud-card { animation: popIn .28s ease-out; }
@keyframes popIn { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 底部触控按钮 */
#touch-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; gap: 12px;
  padding: 0 18px 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 6;
}
#touch-bar .spacer { flex: 1; }
.round-btn {
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; box-shadow: var(--shadow);
  position: relative;
  transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
.round-btn:active { transform: scale(0.93); }
.round-btn.fire { width: 92px; height: 92px; background: var(--accent); font-size: 22px; font-weight: 800; }
.round-btn.chat { width: 60px; height: 60px; background: #6d9eeb; font-size: 26px; }

/* 道具栏：苹果 / 幸运草 / 炸药 */
.bag { display: flex; align-items: flex-end; gap: 10px; }
.bag-btn { width: 68px; height: 68px; font-size: 28px; }
.bag-btn.apple { background: #ffa726; }
.bag-btn.clover { background: #66bb6a; }
.bag-btn.dyn { background: #ef5350; }
.bag-count {
  position: absolute; top: -4px; right: -4px;
  background: #fff; color: #d84315; font-size: 13px; font-weight: 800;
  border-radius: 50%; min-width: 23px; height: 23px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.bag-btn.empty { opacity: .42; filter: grayscale(.55); }
.bag-btn.active { box-shadow: 0 0 0 3px #fff, 0 0 18px 6px rgba(255,246,170,.9); }

/* 遮罩（等待/暂停/提示） */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 25, 12, .72); backdrop-filter: blur(3px);
}
.overlay-box {
  background: var(--card); border-radius: 24px; padding: 30px 28px;
  text-align: center; width: min(80vw, 380px); box-shadow: var(--shadow);
}
.overlay-box h2 { margin: 0 0 10px; color: var(--accent); }
.overlay-box p { color: var(--ink-soft); font-size: 15px; margin: 6px 0 16px; }
.big-code {
  font-size: 52px; font-weight: 900; letter-spacing: 10px; color: var(--accent);
  margin: 10px 0 18px; background: #fff3e0; border-radius: 16px; padding: 12px;
}

/* 聊天面板 */
#chat-panel {
  position: absolute; left: 14px; bottom: 110px; z-index: 8;
  width: min(56vw, 320px);
  background: rgba(255,250,242,.94); border-radius: 16px; padding: 10px;
  box-shadow: var(--shadow);
}
#chat-messages { max-height: 30vh; overflow-y: auto; font-size: 14px; line-height: 1.5; margin-bottom: 8px; }
.chat-line { margin: 4px 0; }
.chat-line .who { font-weight: 700; }
.chat-line.A .who { color: var(--accent); }
.chat-line.B .who { color: #36c5a0; }
.chat-line.sys { color: var(--ink-soft); font-style: italic; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; padding: 10px; border: 2px solid #ffd9b0; border-radius: 12px; font-size: 15px; outline: none; }
.chat-input-row .btn { width: auto; padding: 10px 14px; font-size: 15px; }

/* 连接状态条 */
.conn-banner {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  background: #ef5350; color: #fff; padding: 8px 18px; border-radius: 20px;
  font-size: 14px; z-index: 30; box-shadow: var(--shadow);
}

/* 结算界面 */
#screen-over { background: linear-gradient(160deg, #fff3e0, #ffd0a0); }
.over-card {
  width: min(86vw, 440px); background: var(--card); border-radius: 28px;
  padding: 34px 30px; text-align: center; box-shadow: var(--shadow);
}
.over-emoji { font-size: 64px; }
.over-card h2 { margin: 6px 0 14px; color: var(--accent); }
.over-score { font-size: 20px; margin: 6px 0; }
.over-score b, .over-level b { color: var(--accent); font-size: 26px; }
.over-level { color: var(--ink-soft); margin: 4px 0 8px; font-size: 15px; }
.over-level b { font-size: 19px; }
.over-judge { font-size: 15px; color: #c07a2a; margin: 0 0 16px; }
.over-judge.good { color: #3b8f4f; font-weight: 700; }
.over-phrase {
  font-size: 17px; color: var(--accent2); line-height: 1.6;
  background: #fff0f3; border-radius: 16px; padding: 14px; margin: 0 0 22px;
}

/* 竖屏提示（仅竖屏时显示） */
#rotate-tip {
  position: fixed; inset: 0; z-index: 100;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: #2a1c10; color: #fff; text-align: center;
}
#rotate-tip .rotate-icon { font-size: 60px; animation: spin 2s ease-in-out infinite; }
#rotate-tip p { margin-top: 14px; font-size: 18px; }
@keyframes spin { 0%,100%{transform:rotate(0)} 50%{transform:rotate(90deg)} }

/* 竖屏且为触摸设备时，显示横屏提示，隐藏游戏内容 */
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-tip { display: flex; }
  #app { display: none; }
}
