/* ── 变量 ──────────────────────────────────────────────────────────────────── */
:root {
  --bg:        #008080;
  --gray:      #c0c0c0;
  --light:     #ffffff;
  --mid:       #dfdfdf;
  --dark:      #808080;
  --darkest:   #404040;
  --lcd-bg:    #1a1a1a;
  --lcd-red:   #ff2222;
  --cell-size: 28px;
  --tabbar-h:  54px;
  --font:      Arial, Helvetica, sans-serif;
}

/* ── 基础重置 ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: #000;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }

/* ── 菜单栏装饰 ─────────────────────────────────────────────────────────────── */
.win-menubar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--gray);
  border-bottom: 1px solid var(--darkest);
  box-shadow: 0 1px 0 var(--light) inset;
  padding: 2px 6px;
  display: flex;
  gap: 2px;
  font-size: 13px;
  user-select: none;
}

.menu-item {
  padding: 2px 8px;
  border: 1px solid transparent;
  cursor: default;
}

.menu-item:hover {
  background: #000080;
  color: #fff;
  border-color: #000080;
}

/* ── 整体布局 ───────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 32px;
  gap: 16px;
  min-height: calc(100vh - 28px);
}

/* ── 页面标题 ───────────────────────────────────────────────────────────────── */
.page-header {
  text-align: center;
  color: var(--light);
  text-shadow: 1px 1px 2px rgba(0,0,0,.7);
}

.page-header h1 {
  font-size: clamp(20px, 4vw, 32px);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.page-header h2 {
  font-size: clamp(12px, 2.4vw, 18px);
  font-weight: normal;
  opacity: .9;
}

/* ── Tab 面板包装器 ─────────────────────────────────────────────────────────── */
.tab-panels-wrapper {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.tab-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ── Win95 立体边框工具类 ────────────────────────────────────────────────────── */
.win-outset {
  border-top:    3px solid var(--light);
  border-left:   3px solid var(--light);
  border-right:  3px solid var(--darkest);
  border-bottom: 3px solid var(--darkest);
  background: var(--gray);
}

.win-inset {
  border-top:    2px solid var(--dark);
  border-left:   2px solid var(--dark);
  border-right:  2px solid var(--light);
  border-bottom: 2px solid var(--light);
}

/* ── 游戏面板 ───────────────────────────────────────────────────────────────── */
.game-panel {
  padding: 8px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
  flex-shrink: 0;
}

/* ── 难度选项卡 ─────────────────────────────────────────────────────────────── */
.diff-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.diff-btn {
  background: var(--gray);
  border-top:    2px solid var(--light);
  border-left:   2px solid var(--light);
  border-right:  2px solid var(--dark);
  border-bottom: 2px solid var(--dark);
  padding: 3px 11px;
  font-size: 13px;
  min-width: 46px;
  user-select: none;
}

.diff-btn:active,
.diff-btn.active {
  border-top:    2px solid var(--dark);
  border-left:   2px solid var(--dark);
  border-right:  2px solid var(--light);
  border-bottom: 2px solid var(--light);
  padding-top: 4px;
  padding-left: 12px;
}

/* ── 自定义表单 ─────────────────────────────────────────────────────────────── */
.custom-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px;
  font-size: 13px;
}

.custom-form.hidden { display: none; }

.custom-form label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.custom-form input[type="number"] {
  width: 54px;
  border-top:    2px solid var(--dark);
  border-left:   2px solid var(--dark);
  border-right:  2px solid var(--light);
  border-bottom: 2px solid var(--light);
  background: #fff;
  padding: 2px 4px;
  font-size: 13px;
  font-family: var(--font);
}

/* ── 分隔线 ─────────────────────────────────────────────────────────────────── */
.separator {
  height: 4px;
  border-top:    2px solid var(--dark);
  border-bottom: 2px solid var(--light);
}

/* ── 信息栏 ─────────────────────────────────────────────────────────────────── */
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray);
  padding: 6px 10px;
}

/* ── LCD 计数器 ─────────────────────────────────────────────────────────────── */
.lcd {
  font-family: 'Courier New', Courier, monospace;
  font-size: 24px;
  font-weight: bold;
  color: var(--lcd-red);
  background: var(--lcd-bg);
  padding: 2px 6px 2px 4px;
  min-width: 48px;
  text-align: right;
  letter-spacing: 4px;
  line-height: 1.3;
  border-top:    2px solid var(--dark);
  border-left:   2px solid var(--dark);
  border-right:  2px solid var(--light);
  border-bottom: 2px solid var(--light);
  user-select: none;
}

/* ── 笑脸按钮 ───────────────────────────────────────────────────────────────── */
.smiley-btn {
  width: 42px;
  height: 42px;
  font-size: 22px;
  background: var(--gray);
  border-top:    3px solid var(--light);
  border-left:   3px solid var(--light);
  border-right:  3px solid var(--darkest);
  border-bottom: 3px solid var(--darkest);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.smiley-btn:active {
  border-top:    3px solid var(--darkest);
  border-left:   3px solid var(--darkest);
  border-right:  3px solid var(--light);
  border-bottom: 3px solid var(--light);
}

/* ── 棋盘容器 ───────────────────────────────────────────────────────────────── */
.board-outer {
  background: var(--gray);
  padding: 4px;
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.board {
  display: inline-grid;
  gap: 0;
  user-select: none;
  touch-action: manipulation;
}

/* ── 格子样式 ───────────────────────────────────────────────────────────────── */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.58);
  font-weight: 900;
  font-family: var(--font);
  position: relative;
  line-height: 1;
  overflow: hidden;
  flex-shrink: 0;
}

.cell-covered {
  background: var(--gray);
  border-top:    2px solid var(--light);
  border-left:   2px solid var(--light);
  border-right:  2px solid var(--dark);
  border-bottom: 2px solid var(--dark);
  cursor: pointer;
}

.cell-covered:active {
  border: 1px solid var(--dark);
  padding-top: 1px;
  padding-left: 1px;
}

.cell-revealed {
  background: var(--gray);
  border: 1px solid var(--dark);
}

.cell-mine {
  background: var(--gray);
  border: 1px solid var(--dark);
}

.cell-exploded {
  background: #ff3333;
  border: 1px solid #cc0000;
}

.cell-wrong {
  background: var(--gray);
  border: 1px solid var(--dark);
}

.wrong-x {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cc0000;
  font-size: calc(var(--cell-size) * 0.75);
  font-weight: 900;
  pointer-events: none;
  z-index: 3;
}

/* ── AI 提示遮罩 ────────────────────────────────────────────────────────────── */
.cell[data-hint]::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.cell[data-hint="mine"]::after   { background: rgba(200,  0,  0, 0.52); }
.cell[data-hint="danger"]::after { background: rgba(255, 80,  0, 0.38); }
.cell[data-hint="mid"]::after    { background: rgba(255,200,  0, 0.28); }
.cell[data-hint="low"]::after    { background: rgba(  0,200, 50, 0.38); }
.cell[data-hint="safe"]::after   { background: rgba(  0,160,  0, 0.52); }

/* ── AI 操作栏 ──────────────────────────────────────────────────────────────── */
.ai-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Win95 按钮 ─────────────────────────────────────────────────────────────── */
.win-btn {
  background: var(--gray);
  border-top:    2px solid var(--light);
  border-left:   2px solid var(--light);
  border-right:  2px solid var(--darkest);
  border-bottom: 2px solid var(--darkest);
  padding: 4px 12px;
  font-size: 13px;
  user-select: none;
  white-space: nowrap;
}

.win-btn:active:not(:disabled) {
  border-top:    2px solid var(--darkest);
  border-left:   2px solid var(--darkest);
  border-right:  2px solid var(--light);
  border-bottom: 2px solid var(--light);
  padding-top: 5px;
  padding-left: 13px;
}

.win-btn:disabled {
  color: var(--dark);
  cursor: default;
}

/* ── 内容卡片 ───────────────────────────────────────────────────────────────── */
.content-card {
  background: #fff;
  border: 1px solid #ccc;
  border-top: 2px solid var(--dark);
  border-left: 2px solid var(--dark);
  padding: 18px 22px;
  max-width: 740px;
  width: 100%;
  font-size: 14px;
  line-height: 1.75;
  color: #222;
}

.content-card h3 {
  font-size: 15px;
  font-weight: bold;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gray);
  color: #000080;
}

.content-card h4 {
  font-size: 14px;
  font-weight: bold;
  margin: 14px 0 6px;
  color: #222;
}

.content-card p { margin-bottom: 8px; }

.content-card ul,
.content-card ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.content-card li { margin-bottom: 5px; }

.content-card dl dt {
  font-weight: bold;
  margin-top: 12px;
  color: #111;
}

.content-card dl dd {
  margin-left: 0;
  margin-top: 3px;
  color: #444;
}

.content-card a { color: #0044cc; }
.content-card a:hover { text-decoration: underline; }

/* ── 成绩表格 ───────────────────────────────────────────────────────────────── */
.records-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 14px;
}

.records-table th,
.records-table td {
  border: 1px solid #ccc;
  padding: 8px 16px;
  text-align: center;
}

.records-table th {
  background: var(--gray);
  font-weight: bold;
}

.records-table .best-time {
  color: #007b00;
  font-weight: bold;
}

/* ── 广告位 ─────────────────────────────────────────────────────────────────── */
.ad-slot {
  width: 100%;
  max-width: 740px;
  height: 60px;
  border: 2px dashed #999;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #666;
  text-align: center;
  flex-shrink: 0;
}

.ad-slot a { color: #0044cc; }

/* ── 页脚 ───────────────────────────────────────────────────────────────────── */
.page-footer {
  text-align: center;
  color: var(--light);
  font-size: 12px;
  line-height: 1.8;
  text-shadow: 1px 1px 1px rgba(0,0,0,.6);
  padding-bottom: 4px;
}

.page-footer a { color: #aad4ff; }
.footer-desc { opacity: .8; }

/* ── 辅助文字 ───────────────────────────────────────────────────────────────── */
.tip {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-top: 6px;
}

/* ── 底部 Tab 导航 ───────────────────────────────────────────────────────────── */
.tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-h);
  background: var(--gray);
  border-top: 2px solid var(--dark);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  border-right: 1px solid var(--dark);
  font-size: 10px;
  color: var(--darkest);
  padding: 6px 0 4px;
  transition: color .1s, background .1s;
  user-select: none;
}

.tab-btn:last-child { border-right: none; }

.tab-btn.active {
  color: #000080;
  background: rgba(0,0,128,.1);
  border-top: 2px solid #000080;
}

/* ── 移动端响应式 ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  .tabbar { display: flex; }

  .layout {
    padding: 8px 8px calc(var(--tabbar-h) + 12px);
    gap: 10px;
  }

  .win-menubar { display: none; }

  /* 移动端只显示激活的面板 */
  .tab-panel { display: none; }
  .tab-panel.active { display: flex; }

  .page-header h1 { font-size: 18px; }
  .page-header h2 { font-size: 12px; }

  .game-panel { padding: 6px; gap: 5px; }

  .diff-tabs { gap: 3px; }
  .diff-btn  { padding: 3px 8px; font-size: 12px; min-width: 40px; }

  .info-bar { padding: 4px 8px; }

  .lcd {
    font-size: 20px;
    padding: 2px 4px;
    letter-spacing: 3px;
    min-width: 42px;
  }

  .smiley-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .win-btn { font-size: 12px; padding: 4px 10px; }

  .content-card { padding: 14px 16px; }

  .ad-slot { height: 50px; font-size: 12px; }
}

/* ── 桌面端：所有面板可见 ───────────────────────────────────────────────────── */
@media (min-width: 769px) {
  .tab-panel { display: flex !important; }
  .tabbar    { display: none  !important; }
  .layout    { padding-bottom: 32px; }
}

/* ── 深色系统偏好（简单适配） ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
