/* Go Quest - 棋境物语 全局样式 */

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2C3E2D;
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(91, 140, 90, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(184, 134, 11, 0.08) 0%, transparent 50%);
  font-family: "Yuanti SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #2C2C2C;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== Game Container ===== */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: #F5F0E8;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* PC 端：给游戏容器添加装饰阴影和圆角 */
@media (min-width: 640px) {
  #game-container {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3), 0 0 80px rgba(91, 140, 90, 0.1);
    border-left: 1px solid rgba(92, 64, 51, 0.15);
    border-right: 1px solid rgba(92, 64, 51, 0.15);
  }
}

/* ===== Canvas Layers ===== */
#canvas-container {
  position: relative;
  width: 100%;
  flex-shrink: 0;
}

#canvas-container canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#canvas-bg {
  z-index: 1;
}

#canvas-board {
  z-index: 2;
}

#canvas-ui {
  z-index: 3;
  touch-action: none;
}

/* ===== UI Overlay ===== */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* ===== Loading Screen ===== */
#loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #F5F0E8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading-screen .title {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 36px;
  color: #2C2C2C;
  margin-bottom: 24px;
}

#loading-screen .progress-bar {
  width: 200px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  overflow: hidden;
}

#loading-screen .progress-fill {
  height: 100%;
  background: #5B8C5A;
  width: 0%;
  transition: width 0.3s;
}

#loading-screen .loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: #999;
}

/* ===== Common UI Styles ===== */
.gq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-family: "Yuanti SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  outline: none;
}

/* JUICE: 按钮悬停光晕 + 缩放 */
.gq-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(91, 140, 90, 0.3);
}

.gq-btn:active {
  transform: scale(0.92);
  opacity: 0.85;
  transition: transform 0.08s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.08s;
}

.gq-btn-primary {
  background: #5B8C5A;
  color: #F5F0E8;
}

.gq-btn-secondary {
  background: transparent;
  color: #5B8C5A;
  border: 2px solid #5B8C5A;
}

.gq-btn-danger {
  background: #C94A3A;
  color: #F5F0E8;
}

/* JUICE: 各按钮类型的悬停光晕颜色 */
.gq-btn-primary:hover {
  box-shadow: 0 0 14px rgba(91, 140, 90, 0.4);
}

.gq-btn-danger:hover {
  box-shadow: 0 0 14px rgba(201, 74, 58, 0.4);
}

.gq-btn-secondary:hover {
  box-shadow: 0 0 14px rgba(91, 140, 90, 0.25);
}

.gq-btn-gold {
  background: linear-gradient(135deg, #B8860B, #DAA520);
  color: #F5F0E8;
}

.gq-btn-small {
  min-height: 36px;
  padding: 6px 16px;
  font-size: 14px;
}

.gq-btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: rgba(245, 240, 232, 0.8);
  color: #2C2C2C;
  font-size: 20px;
}

/* ===== Dialog ===== */
.gq-dialog-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: gq-fadeIn 0.2s;
}

/* JUICE: 对话框背景淡入带轻微缩放 */
.gq-dialog-backdrop {
  animation: gq-fadeScaleIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* JUICE: 对话框弹出使用 easeOutBack 弹性动画 */
.gq-dialog {
  background: #F5F0E8;
  border-radius: 16px;
  padding: 24px;
  max-width: 340px;
  width: 85%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(92, 64, 51, 0.2);
  animation: gq-bounceIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gq-dialog-title {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 22px;
  text-align: center;
  margin-bottom: 12px;
  color: #2C2C2C;
}

.gq-dialog-message {
  font-size: 15px;
  text-align: center;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.5;
}

.gq-dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.gq-dialog-buttons .gq-btn {
  flex: 1;
  max-width: 140px;
}

/* ===== Master Dialog ===== */
/* JUICE: 师父对话框弹跳入场动画 */
.gq-master-dialog {
  position: absolute;
  bottom: 16px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 40;
  animation: gq-masterBounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gq-master-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid #B8860B;
  object-fit: cover;
  flex-shrink: 0;
  background: #F5F0E8;
}

.gq-master-bubble {
  position: relative;
  background: rgba(245, 240, 232, 0.95);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #2C2C2C;
  border: 1px solid rgba(92, 64, 51, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: calc(100% - 88px);
}

.gq-master-bubble::before {
  content: '';
  position: absolute;
  bottom: 12px;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid rgba(245, 240, 232, 0.95);
}

/* ===== Top Bar ===== */
.gq-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: rgba(245, 240, 232, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(92, 64, 51, 0.15);
  z-index: 30;
}

.gq-top-bar .level-name {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #2C2C2C;
}

.gq-top-bar .bar-info {
  font-size: 13px;
  color: #666;
  margin: 0 8px;
}

/* ===== Toast ===== */
.gq-toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(44, 44, 44, 0.9);
  color: #F5F0E8;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 60;
  animation: gq-fadeIn 0.2s;
}

.gq-toast.hide {
  animation: gq-fadeOut 0.3s forwards;
}

/* ===== Stars ===== */
.gq-stars {
  display: inline-flex;
  gap: 4px;
}

.gq-star {
  font-size: 20px;
  line-height: 1;
}

.gq-star-filled {
  color: #DAA520;
}

.gq-star-empty {
  color: #ccc;
}

/* ===== Chapter/Level Cards ===== */
.gq-card-list {
  width: 100%;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gq-card {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(92, 64, 51, 0.1);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

/* JUICE: 卡片悬停轻微上浮 + 阴影 */
.gq-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.gq-card:active {
  transform: scale(0.97);
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gq-card.locked {
  opacity: 0.5;
  cursor: default;
}

.gq-card.locked:active {
  transform: none;
}

.gq-card-title {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 18px;
  color: #2C2C2C;
  margin-bottom: 4px;
}

.gq-card-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

.gq-card-stars {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #B8860B;
}

.gq-card-lock {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 20px;
  opacity: 0.5;
}

/* ===== Scene-specific ===== */
.gq-title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.gq-title-name {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 42px;
  color: #2C2C2C;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gq-title-subtitle {
  font-size: 18px;
  color: #5B8C5A;
  letter-spacing: 4px;
  margin-bottom: 32px;
}

.gq-title-rank {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.gq-title-rank img {
  width: 40px;
  height: 40px;
}

.gq-title-rank .rank-name {
  font-size: 16px;
  color: #B8860B;
  font-weight: 600;
}

.gq-title-stars-info {
  font-size: 14px;
  color: #888;
  margin-bottom: 32px;
}

.gq-title-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 260px;
}

.gq-title-footer {
  position: absolute;
  bottom: 16px;
  font-size: 12px;
  color: #aaa;
}

/* ===== Result Screen ===== */
/* JUICE: 结算画面带缩放淡入 */
.gq-result-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: rgba(245, 240, 232, 0.95);
  animation: gq-fadeScaleIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.gq-result-title {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 28px;
  color: #B8860B;
  margin-bottom: 16px;
}

.gq-result-stars {
  margin-bottom: 20px;
}

.gq-result-stars .gq-star {
  font-size: 36px;
}

.gq-result-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.gq-result-stat {
  text-align: center;
}

.gq-result-stat .value {
  font-size: 24px;
  font-weight: 700;
  color: #2C2C2C;
}

.gq-result-stat .label {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.gq-result-concept {
  font-size: 14px;
  color: #5B8C5A;
  margin-bottom: 24px;
  padding: 8px 16px;
  background: rgba(91, 140, 90, 0.1);
  border-radius: 8px;
}

.gq-result-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== Rank Up Screen ===== */
.gq-rankup-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle, rgba(184, 134, 11, 0.15), transparent 70%);
}

.gq-rankup-title {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 32px;
  color: #B8860B;
  margin-bottom: 24px;
}

.gq-rankup-badge {
  width: 120px;
  height: 120px;
  margin-bottom: 16px;
  animation: gq-pulse 1.5s infinite;
}

.gq-rankup-name {
  font-size: 24px;
  font-weight: 700;
  color: #2C2C2C;
  margin-bottom: 32px;
}

/* ===== Pause Screen ===== */
.gq-pause-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.6);
}

.gq-pause-title {
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 28px;
  color: #F5F0E8;
  margin-bottom: 16px;
}

/* ===== Scene header with back button ===== */
.gq-scene-header {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  flex-shrink: 0;
}

.gq-scene-header .back-btn {
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  color: #2C2C2C;
  background: none;
  border: none;
}

.gq-scene-header .header-title {
  flex: 1;
  text-align: center;
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 20px;
  color: #2C2C2C;
}

/* ===== Animations ===== */
@keyframes gq-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes gq-fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes gq-scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes gq-slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes gq-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* JUICE: 对话框弹跳入场 */
@keyframes gq-bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.08); opacity: 1; }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

/* JUICE: 淡入+微缩放（场景转场用） */
@keyframes gq-fadeScaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* JUICE: 师父对话框弹跳入场 */
@keyframes gq-masterBounceIn {
  0% { transform: translateY(40px) scale(0.9); opacity: 0; }
  60% { transform: translateY(-6px) scale(1.03); opacity: 1; }
  80% { transform: translateY(2px) scale(0.99); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* JUICE: 星星飞入动画 - 从下方弹跳入场 + 旋转 + 放大 */
@keyframes gq-starFly {
  0% { transform: scale(0) rotate(-60deg) translateY(30px); opacity: 0; }
  50% { transform: scale(1.4) rotate(15deg) translateY(-5px); opacity: 1; }
  70% { transform: scale(0.9) rotate(-5deg) translateY(2px); opacity: 1; }
  85% { transform: scale(1.1) rotate(3deg) translateY(-1px); opacity: 1; }
  100% { transform: scale(1) rotate(0deg) translateY(0); opacity: 1; }
}

/* JUICE: 获得星星后的持续发光脉冲 */
@keyframes gq-starGlow {
  0%, 100% { text-shadow: 0 0 4px rgba(218, 165, 32, 0.3); }
  50% { text-shadow: 0 0 12px rgba(218, 165, 32, 0.6); }
}

.gq-star-anim {
  display: inline-block;
  animation: gq-starFly 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
}

/* JUICE: 已获得的星星持续微光 */
.gq-star-filled.gq-star-anim {
  animation: gq-starFly 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
             gq-starGlow 2s ease-in-out 0.6s infinite;
}

/* ===== Sound Toggle ===== */
.gq-sound-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: #F5F0E8;
  cursor: pointer;
}

.gq-sound-toggle .icon {
  font-size: 24px;
}

/* ===== Scrollbar ===== */
.gq-card-list::-webkit-scrollbar {
  width: 4px;
}

.gq-card-list::-webkit-scrollbar-thumb {
  background: rgba(92, 64, 51, 0.2);
  border-radius: 2px;
}

/* ===== Safe area ===== */
@supports (padding-top: env(safe-area-inset-top)) {
  .gq-top-bar {
    padding-top: env(safe-area-inset-top);
    height: calc(48px + env(safe-area-inset-top));
  }
}
