@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;700&display=swap');

:root {
  --primary: #8b5a2b; /* 赭石色 */
  --success: #43a047; /* 翠绿 - 修正为更清晰的绿色 */
  --warning: #fb8c00; /* 橘黄 - 修正为更清晰的橙色 */
  --absent: #78909c; /* 石青灰 - 修正为冷灰色以区分 */
  --bg: #fdf5e6; /* 米色宣纸底 */
  --ink: #2f2f2f; /* 墨色 */
}
* { box-sizing: border-box; }
body { 
  margin: 0; 
  font-family: 'Noto Serif SC', 'Songti SC', serif; 
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
  color: var(--ink);
  display: flex; 
  flex-direction: column; 
  min-height: 100vh; 
}

.header { text-align: center; padding: 24px 0 16px; position: relative; border-bottom: 2px solid #8b5a2b; background: rgba(255,255,255,0.4); }
.header h1 { margin: 0; font-size: 32px; color: #5d4037; font-weight: 700; letter-spacing: 2px; text-shadow: 1px 1px 2px rgba(0,0,0,0.1); }
.sub { color: #8b5a2b; font-size: 15px; margin-top: 6px; font-weight: 500; }
.back-btn { position: absolute; top: 24px; left: 20px; text-decoration: none; color: #5d4037; font-size: 15px; border: 1px solid #8b5a2b; padding: 6px 12px; border-radius: 4px; background: transparent; transition: all 0.3s; }
.back-btn:hover { background: #8b5a2b; color: #fff; }

.main { flex: 1; width: 100%; max-width: 520px; margin: 0 auto; padding: 20px 16px; display: flex; flex-direction: column; position: relative; }

.overlay { position: absolute; inset: 0; background: rgba(253,245,230,0.95); z-index: 10; display: grid; place-items: center; }
.overlay .card { 
  width: 96%; max-width: 420px; 
  background: #fffbf0; 
  border: 2px solid #8b5a2b; 
  border-radius: 8px; 
  padding: 32px; 
  box-shadow: 0 12px 24px rgba(47,47,47,0.15); 
  text-align: center; 
  position: relative;
}
.overlay .card::before {
  content: ''; position: absolute; top: 4px; left: 4px; right: 4px; bottom: 4px; 
  border: 1px solid #d2b48c; border-radius: 4px; pointer-events: none;
}
.overlay h2 { margin: 0 0 10px; font-size: 26px; color: #5d4037; }
.overlay .tip { margin: 0 0 20px; color: #8b5a2b; font-size: 15px; }
.overlay .primary { padding: 10px 24px; border-radius: 4px; background: #8b5a2b; color: white; border: none; cursor: pointer; font-family: inherit; font-size: 16px; letter-spacing: 1px; transition: 0.2s; }
.overlay .primary:hover { background: #6d4621; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.mode button { background: rgba(255,255,255,0.6); border: 1px solid #8b5a2b; padding: 5px 12px; border-radius: 4px; cursor: pointer; color: #5d4037; font-size: 14px; margin-right: 8px; font-family: inherit; }
.mode button:hover { background: #8b5a2b; color: #fff; }
.message { font-weight: 600; color: var(--success); min-height: 28px; font-size: 16px; text-shadow: 0 1px 0 rgba(255,255,255,0.8); }

.grid { display: grid; gap: 8px; margin-bottom: 16px; }
.row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cell { 
  background: #fff; 
  border: 2px solid #d2b48c; 
  border-radius: 6px; 
  min-height: 90px; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  position: relative; 
  box-shadow: 2px 2px 5px rgba(0,0,0,0.05);
}
.tags { display: flex; gap: 3px; position: absolute; top: 6px; left: 0; right: 0; justify-content: center; }
.tag { font-size: 11px; padding: 2px 4px; border-radius: 2px; background: #f0e6d2; color: #5d4037; min-width: 16px; text-align: center; border: 1px solid transparent; }
.tag.correct { background: var(--success); color: #fff; border-color: transparent; }
.tag.present { background: var(--warning); color: #fff; border-color: transparent; }
.tag.absent { background: var(--absent); color: #fff; border-color: transparent; }
.tag.combo-match { }
.pinyin-group { display: flex; gap: 2px; position: relative; }
.pinyin-group.combo-match::after { content: ''; position: absolute; bottom: -4px; left: 0; right: 0; height: 3px; background: #d4a017; border-radius: 2px; }

.char { font-size: 32px; font-weight: 700; color: #2f2f2f; margin-top: 18px; font-family: 'KaiTi', '楷体', 'STKaiti', serif; }

@media (max-width: 420px) {
  .cell { min-height: 80px; }
  .char { font-size: 26px; }
}

.hint {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: rgba(255,255,255,0.5);
  border: 1px solid #d2b48c;
  border-radius: 8px;
  padding: 16px;
}
.hint .cell { min-height: 86px; border-color: #d2b48c; box-shadow: none; background: transparent; }
.hint .tag { color: #5d4037; background: #fdf5e6; border-color: #d2b48c; }
.hint .tag.correct { background: var(--success); color: #fff; border-color: transparent; }
.hint .tag.present { background: var(--warning); color: #fff; border-color: transparent; }
.hint .tag.absent { background: var(--absent); color: #fff; border-color: transparent; }

.guide { margin-bottom: 20px; background: rgba(255,255,255,0.6); border: 1px solid #d2b48c; padding: 16px; border-radius: 6px; font-size: 14px; color: #5d4037; line-height: 1.6; }
.c-badge { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin: 0 3px; vertical-align: middle; border: 1px solid rgba(0,0,0,0.1); }
.c-badge.present { background: var(--warning); }
.c-badge.correct { background: var(--success); }
.c-badge.absent { background: var(--absent); }

.inputbar { display: flex; gap: 10px; margin-top: auto; padding-top: 16px; border-top: 1px solid #d2b48c; }
.inputbar input { 
  flex: 1; padding: 12px; 
  border: 2px solid #d2b48c; 
  border-radius: 6px; 
  font-size: 18px; 
  outline: none; 
  background: rgba(255,255,255,0.8);
  font-family: 'KaiTi', '楷体', serif;
  color: #2f2f2f;
}
.inputbar input:focus { border-color: #8b5a2b; box-shadow: 0 0 0 3px rgba(139,90,43,0.1); }
.inputbar button { padding: 0 20px; background: #2f2f2f; color: #fdf5e6; border: none; border-radius: 6px; font-weight: 500; cursor: pointer; white-space: nowrap; font-family: inherit; font-size: 15px; letter-spacing: 1px; }
.inputbar button:hover { background: #000; }
.inputbar button:disabled { opacity: 0.6; cursor: not-allowed; }
.inputbar #hintBtn, .inputbar #queryBtn { background: #fff; color: #5d4037; border: 1px solid #d2b48c; }
.inputbar #hintBtn:hover, .inputbar #queryBtn:hover { background: #fdf5e6; border-color: #8b5a2b; }

.footer { text-align: center; padding: 24px; color: #8b5a2b; font-size: 13px; opacity: 0.8; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(47,47,47,0.6); z-index: 40; backdrop-filter: blur(2px); overscroll-behavior: none; }
.modal-box { 
  width: 96%; max-width: 520px; 
  background: #fdf5e6; 
  border: 2px solid #8b5a2b; 
  border-radius: 8px; 
  padding: 24px 28px; 
  box-shadow: 0 16px 48px rgba(0,0,0,0.3); 
  position: relative; 
  color: #2f2f2f;
  max-height: 90vh; 
  overflow: hidden;
}
.modal-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; color: #5d4037; text-align: center; border-bottom: 1px solid #d2b48c; padding-bottom: 10px; }
.modal-body { font-size: 16px; color: #2f2f2f; display: grid; gap: 10px; line-height: 1.7; }
.modal-close { position: absolute; top: 12px; right: 12px; background: transparent; border: none; font-size: 20px; cursor: pointer; color: #8b5a2b; }
.modal-close:hover { color: #5d4037; }

/* Query Modal Styles */
.query-box { max-width: 600px; background: #fffbf0; }
.query-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.query-col { display: flex; flex-direction: column; gap: 8px; }
.col-label { font-size: 14px; font-weight: bold; text-align: center; color: #8b5a2b; font-family: 'KaiTi', serif; }
.q-input { 
  width: 100%; padding: 8px; font-size: 14px; 
  border: 1px solid #d2b48c; border-radius: 4px; 
  text-align: center; background: rgba(255,255,255,0.8);
  font-family: inherit;
}
.q-input:focus { border-color: #8b5a2b; outline: none; }
.query-actions { text-align: center; margin-bottom: 16px; }
.query-extra { margin-bottom: 16px; }
.query-actions .primary { padding: 8px 32px; background: #8b5a2b; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: 500; font-family: inherit; font-size: 15px; }
.query-result { max-height: 60vh; overflow-y: auto; border: 1px solid #d2b48c; border-radius: 4px; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; background: rgba(255,255,255,0.4); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.result-item { padding: 8px; background: #fdf5e6; border: 1px solid #eaddcf; border-radius: 4px; text-align: center; font-size: 16px; color: #2f2f2f; cursor: pointer; font-family: 'KaiTi', serif; transition: 0.2s; }
.result-item:hover { background: #8b5a2b; color: #fff; border-color: #8b5a2b; }
.result-item .pinyin { font-size: 11px; color: #8b5a2b; margin-top: 4px; font-family: sans-serif; }
.result-item:hover .pinyin { color: #eaddcf; }
