/* 元素記号表（色分けは元の website_test と同じ） */
:root {
  --bg: #fdfcf8;
  --ink: #333;
  --muted: #777;
  --accent: #ff8c00;
  --link: #6d5efc;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
a { color: var(--link); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px;
}
.brand { font-weight: 800; letter-spacing: .08em; color: var(--ink); text-decoration: none; }
.home { font-size: .9em; text-decoration: none; }

main { max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; text-align: center; }
h1 { color: var(--accent); margin: 8px 0 4px; scroll-margin-top: 16px; }
.lead { margin: 0 0 20px; color: var(--muted); }

/* 周期表（18列 × 7周期 + 間 + 欄外2行） */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 2px 10px; }
.grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(46px, 1fr));
  grid-template-rows: repeat(7, auto) 14px repeat(2, auto);
  gap: 5px;
  min-width: 900px;
}
.cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  padding: 4px;
  color: #333;
  text-decoration: none;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, .1);
  transition: transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  min-width: 0;
}
.cell:hover, .cell:focus-visible { transform: translateY(-3px); box-shadow: 4px 4px 8px rgba(0, 0, 0, .15); z-index: 1; }
.num { font-size: .65em; position: absolute; top: 4px; left: 5px; opacity: .7; }
.sym { font-size: 1.4em; font-weight: bold; line-height: 1.1; }
.name { font-size: .58em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.placeholder { display: flex; align-items: center; justify-content: center; font-size: .75em; color: #666; }
.scroll-hint { display: none; font-size: .8em; color: var(--muted); margin: 0; }
@media (max-width: 920px) { .scroll-hint { display: block; } }

/* 分類ごとの色 */
.cat-nonmetal { background: #a8e6cf; }
.cat-noble-gas { background: #dcedc1; }
.cat-alkali { background: #ffaaa5; }
.cat-alkaline-earth { background: #ffd3b6; }
.cat-metalloid { background: #fff5ba; }
.cat-halogen { background: #ace7ef; }
.cat-transition { background: #c7ceea; }
.cat-other-metal { background: #e2f0cb; }
.cat-lanthanoid { background: #ffc3a0; }
.cat-actinoid { background: #ff9a9e; }

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  padding: 0;
  margin: 18px 0 36px;
  font-size: .85em;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* 解説 */
.details { max-width: 800px; margin: 0 auto; text-align: left; }
.detail {
  scroll-margin-top: 16px;
  background: #fff;
  border-left: 5px solid #ddd;
  padding: 16px 20px;
  margin-bottom: 16px;
  border-radius: 0 8px 8px 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .05);
}
.detail:target { box-shadow: 0 0 0 3px rgba(255, 140, 0, .35); }
.detail header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.d-sym { font-size: 2.2em; font-weight: bold; color: #555; }
.d-name { font-size: 1.4em; }
.d-cat { font-size: .8em; color: var(--muted); }
.d-no { margin-left: auto; font-size: 1.1em; color: #888; }
.detail p { margin: 0 0 6px; }
.back { font-size: .85em; text-decoration: none; }

.detail-nonmetal { border-color: #a8e6cf; }
.detail-noble-gas { border-color: #dcedc1; }
.detail-alkali { border-color: #ffaaa5; }
.detail-alkaline-earth { border-color: #ffd3b6; }
.detail-metalloid { border-color: #fff5ba; }
.detail-halogen { border-color: #ace7ef; }
.detail-transition { border-color: #c7ceea; }
.detail-other-metal { border-color: #e2f0cb; }
.detail-lanthanoid { border-color: #ffc3a0; }
.detail-actinoid { border-color: #ff9a9e; }

.foot { text-align: center; font-size: .85em; color: var(--muted); padding: 24px 16px 32px; }
