:root {
  --primary-red: #d63031;
  --bg-color: #f7f9fa;
  --card-bg: #ffffff;
  --text-main: #2d3436;
  --text-sub: #636e72;
  --accent-yellow: #fdcb6e;
  --highlight-bg: #ffeb3b4d;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  --accent-green: #00b894;
}

body {
  font-family:
    "PingFang TC", "Microsoft JhengHei", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  background-color: var(--bg-color);
  margin: 0;
  padding: 20px;
  color: var(--text-main);
  line-height: 1.6;
}

/* 預防 CLS */
img {
  height: auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 30px;
  padding: 40px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #fff5f5 100%);
  border-radius: 20px;
  box-shadow: 0 10px 20px rgba(214, 48, 49, 0.1);
  border-bottom: 5px solid var(--primary-red);
  position: relative;
  overflow: hidden;
}

header::before {
  content: "🇮🇩";
  font-size: 10rem;
  position: absolute;
  top: -20px;
  right: -20px;
  opacity: 0.05;
  transform: rotate(15deg);
  pointer-events: none;
}

h1 {
  color: var(--primary-red);
  font-size: 2.5rem;
  margin: 0 0 10px 0;
  font-weight: 900;
  letter-spacing: 1px;
}

p.subtitle {
  color: var(--text-sub);
  font-size: 1.1rem;
  margin: 0;
}

/* 吸附式搜尋列 */
.sticky-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(247, 249, 250, 0.95);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 10px 0;
  margin-bottom: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  border-radius: 0 0 20px 20px;
}

.controls {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.search-box {
  width: 90%;
  max-width: 400px;
  padding: 12px 20px;
  border-radius: 30px;
  border: 2px solid #e1e1e1;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

.search-box:focus {
  border-color: var(--primary-red);
  box-shadow: 0 0 0 4px rgba(214, 48, 49, 0.1);
}

.filter-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 0 10px;
}

.filter-btn {
  background: white;
  border: 1px solid #dfe6e9;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  color: var(--text-sub);
  font-weight: 500;
  white-space: nowrap;
}

.filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.filter-btn.active {
  background: var(--primary-red);
  color: white;
  border-color: var(--primary-red);
  box-shadow: 0 4px 10px rgba(214, 48, 49, 0.3);
}

.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 10px;
  min-height: 50vh;
}

.no-result {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: #888;
  font-size: 1.2rem;
  display: none;
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
  transition:
    transform 0.3s,
    box-shadow 0.3s;
  position: relative;
  display: flex;
  flex-direction: column;
  border-top: 5px solid #ddd;
  content-visibility: auto;
  contain-intrinsic-size: 350px;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  z-index: 10;
}
.card[hidden] {
  display: none !important;
}

/* 卡片顏色 */
.card[data-cat="intro"] {
  border-top-color: #ff7675;
}
.card[data-cat="compliment"] {
  border-top-color: #fdcb6e;
}
.card[data-cat="social"] {
  border-top-color: #55efc4;
}
.card[data-cat="smalltalk"] {
  border-top-color: #81ecec;
}
.card[data-cat="titles"] {
  border-top-color: #74b9ff;
}
.card[data-cat="attitude"] {
  border-top-color: #a29bfe;
}
.card[data-cat="money"] {
  border-top-color: #00cec9;
}
.card[data-cat="number"] {
  border-top-color: #dfe6e9;
}
.card[data-cat="food"] {
  border-top-color: #fab1a0;
}
.card[data-cat="location"] {
  border-top-color: #0984e3;
}
.card[data-cat="traffic"] {
  border-top-color: #636e72;
}
.card[data-cat="time"] {
  border-top-color: #e84393;
}
.card[data-cat="medical"] {
  border-top-color: #d63031;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.id-badge {
  font-size: 0.8rem;
  font-weight: bold;
  color: #b2bec3;
  background: #f1f2f6;
  padding: 3px 8px;
  border-radius: 6px;
}
.cat-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f2f6;
  color: #636e72;
}

.emoji-display {
  font-size: 2.5rem;
  margin: 10px 0;
  text-align: center;
  min-height: 1.2em;
}

.word-block {
  text-align: center;
  margin-bottom: 20px;
  position: relative;
}

.audio-btn {
  background: #fff0f0;
  border: none;
  color: var(--primary-red);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s;
  margin-left: 10px;
  vertical-align: middle;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  -webkit-tap-highlight-color: transparent;
}
.audio-btn:hover {
  background: var(--primary-red);
  color: white;
  transform: scale(1.1);
}
.audio-btn:active {
  transform: scale(0.95);
}

.indo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
  line-height: 1.2;
  display: inline-block;
}
.mean {
  font-size: 1.1rem;
  color: var(--primary-red);
  font-weight: 500;
  margin-top: 5px;
}

.info-section {
  background: #fffbf0;
  border-left: 4px solid var(--accent-yellow);
  padding: 12px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 12px;
}
.info-section.brain {
  background: #f0fdf4;
  border-left-color: var(--accent-green);
}

.label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #aaa;
  font-weight: bold;
  display: block;
  margin-bottom: 4px;
}
.sound-text {
  font-size: 1.3rem;
  font-weight: bold;
  color: #2d3436;
}
.story-text {
  font-size: 0.95rem;
  color: #444;
}

.highlight {
  color: var(--primary-red);
  font-weight: 800;
  background: var(--highlight-bg);
  padding: 0 4px;
  border-radius: 4px;
  margin: 0 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.note-box {
  margin-top: auto;
  background: #eef7fc;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #576574;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* 回到頂部按鈕 */
#backToTopBtn {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99;
  font-size: 1.2rem;
  border: none;
  outline: none;
  background-color: var(--primary-red);
  color: white;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(214, 48, 49, 0.4);
  transition: all 0.3s;
}
#backToTopBtn:hover {
  background-color: #b71c1c;
  transform: translateY(-3px);
}

/* --- Footer 專用美化 (修正問題的核心) --- */
footer {
  text-align: center;
  padding: 50px 20px 30px;
  color: #b2bec3;
  font-size: 0.9rem;
  background: linear-gradient(to bottom, transparent, #fff5f5 80%);
  margin-top: 40px;
  border-top: 1px solid #f0f0f0;
}

.love-note {
  color: var(--primary-red);
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.audio-hint {
  font-size: 0.85rem;
  margin-bottom: 25px;
  opacity: 0.8;
}

/* 喝咖啡按鈕樣式 */
.coffee-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #ffdd00;
  color: #333;
  text-decoration: none;
  padding: 10px 24px;
  border-radius: 50px;
  font-weight: bold;
  font-size: 0.95rem;
  box-shadow: 0 4px 10px rgba(255, 221, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  margin-bottom: 30px;
}

.coffee-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 15px rgba(255, 221, 0, 0.4);
  background-color: #ffe63b;
}

.coffee-btn span {
  margin-left: 6px;
}

.copyright {
  font-size: 0.8rem;
  color: #999;
  line-height: 1.8;
}

.copyright a {
  color: #636e72;
  text-decoration: none;
  border-bottom: 1px dashed #ccc;
  transition: color 0.2s;
  padding-bottom: 1px;
}

.copyright a:hover {
  color: var(--primary-red);
  border-bottom-color: var(--primary-red);
}

.copyright-row {
  display: flex;
  justify-content: center;
  gap: 15px;
}
