:root {
  --miku: #39c5bb;
  --miku-dark: #2a948c;
  --miku-light: #86e5de;
  --bg: #0e1518;
  --bg-panel: #162226;
  --bg-cell: #1d2c31;
  --border: #2c4148;
  --text: #e8f4f2;
  --text-dim: #8aa5a1;
  --correct: #2ea86d;
  --partial: #c9a227;
  --absent: #3a4a4f;
  --pink: #e12885;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.header {
  border-bottom: 2px solid var(--miku);
  background: linear-gradient(180deg, #121d21, var(--bg));
  padding: 10px 16px 8px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 860px;
  margin: 0 auto;
}
.title {
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: var(--text);
  text-shadow: 0 0 12px rgba(57, 197, 187, 0.45);
}
.title-accent { color: var(--miku); }
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
@media (hover: hover) {
  .icon-btn:hover { border-color: var(--miku); }
}

.mode-bar {
  max-width: 860px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--miku);
  border-color: var(--miku);
  color: #06302c;
  font-weight: 700;
}
.daily-no { color: var(--text-dim); font-size: 0.8rem; margin-left: auto; }

/* ---------- main ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 12px 32px;
}

.start-hint {
  background: rgba(57, 197, 187, 0.08);
  border: 1px dashed var(--miku);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  line-height: 1.7;
}
.start-hint[hidden] { display: none !important; }
.start-hint-title {
  font-size: 1rem;
  color: var(--miku-light);
  margin-bottom: 6px;
}
.start-hint strong { color: var(--miku-light); }

.guess-area { margin-bottom: 14px; }
.input-wrap { position: relative; }
#guess-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}
#guess-input:focus { border-color: var(--miku); }
#guess-input:disabled { opacity: 0.45; }

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--miku-dark);
  border-radius: 10px;
  list-style: none;
  max-height: 290px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.suggestions li {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.suggestions li.selected { background: rgba(57, 197, 187, 0.15); }
@media (hover: hover) {
  .suggestions li:hover { background: rgba(57, 197, 187, 0.15); }
}
.suggestions .s-title { font-weight: 600; }
.suggestions .s-producer { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }

.guess-count {
  margin-top: 8px;
  text-align: right;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---------- board ---------- */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.board {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
  min-width: 540px;
}
.board th {
  color: var(--miku-light);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 2px;
  letter-spacing: 0.05em;
}
.board th:nth-child(1) { width: 24%; }
.board th:nth-child(2) { width: 17%; }
.board th:nth-child(3) { width: 14%; }
.board th:nth-child(4) { width: 11%; }
.board th:nth-child(5) { width: 23%; }
.board th:nth-child(6) { width: 11%; }

.cell {
  background: var(--bg-cell);
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.35;
  word-break: break-word;
  vertical-align: middle;
  min-height: 52px;
  height: 58px;
  perspective: 600px;
}
.cell-inner {
  opacity: 0;
  transform: rotateX(90deg);
  animation: flip-in 0.45s ease forwards;
}
@keyframes flip-in {
  from { opacity: 0; transform: rotateX(90deg); }
  to   { opacity: 1; transform: rotateX(0deg); }
}
.cell.correct { background: var(--correct); color: #fff; font-weight: 700; }
.cell.partial { background: var(--partial); color: #201a02; font-weight: 700; }
.cell.absent  { background: var(--absent); color: var(--text-dim); }
.cell .arrow { font-size: 0.95rem; margin-left: 2px; }
.cell .sub { display: block; font-size: 0.68rem; opacity: 0.8; }

/* ---------- hint ---------- */
.hint-box {
  margin-top: 16px;
  background: rgba(225, 40, 133, 0.12);
  border: 1px solid var(--pink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
}
.hint-box strong { color: #ff8ec4; }

/* ---------- modal ---------- */
.modal-overlay[hidden],
.suggestions[hidden],
.hint-box[hidden],
.action-btn[hidden] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--miku-dark);
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(57, 197, 187, 0.2);
}
.modal h2 { color: var(--miku-light); margin-bottom: 12px; font-size: 1.2rem; }
.modal h3 { color: var(--miku-light); margin: 14px 0 6px; font-size: 0.95rem; }
.modal p { margin: 8px 0; font-size: 0.9rem; line-height: 1.6; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}
.help-list { list-style: none; margin: 8px 0; }
.help-list li { margin: 6px 0; font-size: 0.88rem; }
.help-list.plain li { margin: 4px 0; color: var(--text); }
.help-note { color: var(--text-dim); font-size: 0.8rem; }
.chip {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-cell);
  font-size: 0.8rem;
  margin-right: 6px;
}
.chip.correct { background: var(--correct); color: #fff; }
.chip.partial { background: var(--partial); color: #201a02; }
.chip.absent { background: var(--absent); }

/* ---------- stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
}
.stat-num { font-size: 1.6rem; font-weight: 700; color: var(--miku); }
.stat-label { font-size: 0.72rem; color: var(--text-dim); }

/* ---------- result ---------- */
.answer-card {
  background: var(--bg-cell);
  border: 1px solid var(--miku-dark);
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
}
.answer-card .a-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--miku-light);
  margin-bottom: 6px;
}
.answer-card .a-row { font-size: 0.85rem; margin: 3px 0; color: var(--text); }
.answer-card .a-row span { color: var(--text-dim); margin-right: 6px; }
.official-media { margin-top: 12px; }
.media-thumb {
  position: relative;
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  line-height: 0;
}
.media-thumb img { width: 100%; display: block; }
.media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  transition: background 0.15s;
}
@media (hover: hover) {
  .media-thumb:hover .media-play { background: rgba(0, 0, 0, 0.05); }
}
.media-nico-embed {
  width: 100%;
  max-width: 320px;
  height: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.media-links { display: flex; gap: 8px; margin-top: 8px; }
.media-link {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  border: 1px solid transparent;
}
.media-link.yt { background: #c4302b; }
.media-link.nico { background: #333; border-color: #555; }
@media (hover: hover) {
  .media-link.yt:hover { background: #e0453f; }
  .media-link.nico:hover { background: #444; }
}
.media-note {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}

.a-theme {
  display: inline-block;
  background: var(--pink);
  color: #fff;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 2px 10px;
  margin-top: 6px;
}
.result-actions { display: flex; gap: 10px; margin-top: 12px; }
.action-btn {
  flex: 1;
  background: var(--miku);
  color: #06302c;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 0.95rem;
  cursor: pointer;
}
.action-btn.secondary { background: var(--bg-cell); color: var(--text); border: 1px solid var(--border); }
.action-btn.x-share { background: #000; color: #fff; border: 1px solid #333; }
@media (hover: hover) {
  .action-btn:hover { background: var(--miku-light); }
  .action-btn.x-share:hover { background: #1a1a1a; }
}

/* ---------- footer ---------- */
.footer {
  text-align: center;
  padding: 14px;
  color: var(--text-dim);
  font-size: 0.7rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .title { font-size: 1.3rem; }
  .cell { font-size: 0.72rem; padding: 8px 4px; }
  .board th { font-size: 0.7rem; }
}
