/* styles/main.css - 掷骰子页面样式（小工具离线版，仅用系统字体与纯 CSS） */

/* ─── Reset & Base ─────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

html { touch-action: manipulation; }

body {
  background: linear-gradient(160deg, #faf8f5 0%, #f0ebe3 50%, #e8e0d5 100%);
  color: #4a4543;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── App Layout ───────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  height: calc(100vh - var(--safe-area-inset-top, 0px) - var(--safe-area-inset-bottom, 0px));
  padding:
    calc(16px + var(--safe-area-inset-top, 0px))
    16px
    calc(16px + var(--safe-area-inset-bottom, 0px));
  gap: 20px;
}

/* ─── 3D 场景容器 ──────────────────────────────── */
.scene-container {
  position: relative;
  width: min(90vw, 90vh, 500px);
  height: min(90vw, 90vh, 500px);
  flex-shrink: 0;
}

#dice-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ─── 结果数字浮现 ─────────────────────────────── */
.result-display {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, 10px);
  font-family: "Georgia", "Times New Roman", "PingFang SC", "Noto Serif SC", serif;
  font-size: 48px;
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 700;
  color: #e8a87c;
  text-shadow:
    0 0 20px rgba(232, 168, 124, 0.35),
    0 0 60px rgba(232, 168, 124, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
  white-space: nowrap;
}

.result-display.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ─── 底部 UI 栏 ───────────────────────────────── */
.ui-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  padding-bottom: var(--safe-area-inset-bottom, 0px);
}

/* ─── 骰子数量选择 ─────────────────────────────── */
.count-control {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(74, 69, 67, 0.08);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.count-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  color: #4a4543;
  background: #fff;
  border: 1px solid rgba(74, 69, 67, 0.12);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.count-btn:active:not(:disabled) {
  transform: scale(0.92);
  background: #7db0a0;
  color: #fff;
  border-color: #7db0a0;
}

.count-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.count-label {
  min-width: 72px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: #4a4543;
  letter-spacing: 0.02em;
}

#dice-count {
  font-family: "Georgia", "Times New Roman", "Noto Serif SC", serif;
  font-size: 20px;
  font-weight: 700;
  color: #e8a87c;
  margin-right: 2px;
}

/* ─── 掷骰子按钮 ───────────────────────────────── */
.roll-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 48px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  background: #7db0a0;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  box-shadow:
    0 4px 16px rgba(125, 176, 160, 0.3),
    0 1px 4px rgba(0, 0, 0, 0.08);
  letter-spacing: 0.04em;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.roll-btn:active {
  transform: scale(0.96);
  background: #6b9e8e;
  box-shadow:
    0 2px 8px rgba(125, 176, 160, 0.35),
    0 1px 4px rgba(0, 0, 0, 0.1);
}

.roll-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(125, 176, 160, 0.15);
}

.touchable:active { opacity: 0.7; }

/* ─── 响应式 ───────────────────────────────────── */
@media (max-width: 480px) {
  #app {
    padding:
      calc(12px + var(--safe-area-inset-top, 0px))
      12px
      calc(12px + var(--safe-area-inset-bottom, 0px));
    gap: 14px;
  }

  .scene-container {
    width: min(92vw, 92vh, 380px);
    height: min(92vw, 92vh, 380px);
  }

  .roll-btn {
    padding: 12px 36px;
    font-size: 16px;
  }
}
