/* ===== Kanji Puzzle (漢字バラバラ) ===== */
:root {
  --game-accent: #F29CB2;
}

body { overflow-x: hidden; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem; background: var(--surface);
  border-bottom: 3px solid var(--color-coral);
  box-shadow: var(--shadow-sm);
}
.top-bar .title { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.top-bar .title a { color: var(--text-muted); }
.top-bar .title span { color: var(--text); font-weight: 900; }
.top-bar-actions { display: flex; gap: .4rem; }
.icon-btn { background: var(--surface2); border: 2px solid var(--surface2); color: var(--text-muted); width: 30px; height: 30px; border-radius: 50%; font-size: .8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: inherit; font-weight: 700; }

.game-page { max-width: 600px; margin: 0 auto; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .6rem; min-height: calc(100vh - 48px); }

/* --- Setup --- */
.setup-section { background: var(--surface); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.setup-section h4 { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; font-weight: 700; }
.player-bar { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.player-bar input { padding: .35rem .6rem; font-size: .85rem; border-radius: 10px; width: 100px; min-width: 0; }
.player-bar .btn { padding: .35rem .6rem; font-size: .8rem; border-radius: 10px; }
.player-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.player-tags .player-tag { font-size: .75rem; padding: .15rem .5rem; }
.options-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .6rem; }
.option-group { display: flex; flex-direction: column; gap: .25rem; }
.option-group label { font-size: .7rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.option-pills { display: flex; gap: .25rem; flex-wrap: wrap; }
.option-pill { padding: .25rem .6rem; font-size: .75rem; border-radius: 999px; border: 2px solid var(--surface2); background: var(--surface); color: var(--text-muted); cursor: pointer; font-family: inherit; font-weight: 600; transition: all .15s; }
.option-pill.selected { background: var(--color-coral); color: #5A3A3A; border-color: transparent; }
.start-btn { margin-top: .8rem; width: 100%; padding: .7rem; font-size: 1.1rem; border-radius: 999px; background: var(--color-coral); color: #5A3A3A; box-shadow: 0 4px 14px rgba(242,156,178,.3); border: none; font-family: inherit; font-weight: 700; cursor: pointer; }
.start-btn:active { transform: scale(.97); }

/* --- Phase Section --- */
.phase-section { background: var(--surface); border-radius: var(--radius); padding: 1.2rem 1rem; box-shadow: var(--shadow); text-align: center; }

/* --- Parts Display --- */
.parts-display {
  position: relative;
  width: 100%;
  min-height: 200px;
  max-width: 360px;
  margin: .5rem auto;
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
}
.part-item {
  position: absolute;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--text);
  transition: all .8s cubic-bezier(.34, 1.56, .64, 1);
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 2px 8px rgba(0,0,0,.08);
  cursor: default;
}
.part-item.scattered {
  opacity: 1;
}
.part-item.assembled {
  animation: assembleGlow .6s ease forwards;
}

@keyframes assembleGlow {
  0% { text-shadow: 0 0 0 transparent; }
  50% { text-shadow: 0 0 20px rgba(242, 156, 178, .6), 0 0 40px rgba(242, 156, 178, .3); transform: scale(1.15); }
  100% { text-shadow: 0 0 8px rgba(242, 156, 178, .3); transform: scale(1); }
}

/* --- Timer --- */
.timer-bar {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  margin: .5rem 0;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--game-accent), rgba(242,156,178,.6));
  border-radius: 3px;
  transition: width .3s linear;
}
.timer-text {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.timer-text.urgent { color: var(--game-accent); font-weight: 900; }

/* --- Question Info --- */
.question-info {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: .3rem;
}
.question-number {
  font-size: 1rem;
  font-weight: 900;
  color: var(--game-accent);
  margin-bottom: .3rem;
}

/* --- Hint Box --- */
.hint-box {
  margin: .4rem auto;
  padding: .4rem .8rem;
  max-width: 320px;
  background: rgba(242, 156, 178, .06);
  border: 2px solid rgba(242, 156, 178, .15);
  border-radius: 12px;
  font-size: .8rem;
  color: var(--text-muted);
  min-height: 1.6em;
  transition: all .3s;
}
.hint-box.active {
  border-color: rgba(242, 156, 178, .3);
  background: rgba(242, 156, 178, .1);
}
.hint-box .hint-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--game-accent);
  text-transform: uppercase;
  margin-bottom: .1rem;
}

/* --- Answer Input --- */
.answer-row {
  display: flex;
  gap: .4rem;
  align-items: center;
  justify-content: center;
  margin-top: .5rem;
  flex-wrap: wrap;
}
.answer-row input[type="text"] {
  padding: .5rem .7rem;
  font-size: 1rem;
  border-radius: 12px;
  width: 160px;
  min-width: 0;
  text-align: center;
  font-weight: 700;
}
.answer-row .btn {
  padding: .5rem 1rem;
  font-size: .9rem;
  border-radius: 12px;
  flex-shrink: 0;
}

/* --- Player Select (shared screen) --- */
.player-select-row {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
  justify-content: center;
  margin-bottom: .4rem;
}
.player-select-btn {
  padding: .3rem .7rem;
  font-size: .8rem;
  border-radius: 999px;
  border: 2px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all .15s;
}
.player-select-btn:hover { border-color: var(--game-accent); }
.player-select-btn.selected { background: var(--color-coral); color: #5A3A3A; border-color: transparent; }

/* --- Feedback --- */
.feedback {
  margin-top: .4rem;
  padding: .5rem .7rem;
  border-radius: 12px;
  font-size: .85rem;
  font-weight: 700;
  display: none;
}
.feedback.show { display: block; }
.feedback.correct { background: rgba(52, 211, 153, .12); border: 2px solid var(--accent-green); color: var(--accent-green); }
.feedback.wrong { background: rgba(242, 156, 178, .08); border: 2px solid var(--game-accent); color: var(--game-accent); }
.feedback.timeout { background: rgba(251, 191, 36, .1); border: 2px solid var(--accent-yellow); color: var(--accent-yellow); }

/* --- Assembled Answer Display --- */
.assembled-display {
  font-size: 3rem;
  font-weight: 900;
  color: var(--game-accent);
  margin: .3rem 0;
  opacity: 0;
  transform: scale(.5);
  transition: all .5s cubic-bezier(.34, 1.56, .64, 1);
}
.assembled-display.show {
  opacity: 1;
  transform: scale(1);
}
.reading-display {
  font-size: .9rem;
  color: var(--text-muted);
  font-weight: 600;
}
.explain-display {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .3rem;
  line-height: 1.5;
}

/* --- Result Section --- */
.result-section { text-align: center; }
.result-icon { font-size: 3rem; margin-bottom: .3rem; }
.result-title { font-size: 1.3rem; font-weight: 900; margin-bottom: .3rem; }
.result-details { font-size: .85rem; color: var(--text-muted); line-height: 1.8; }
.result-details strong { color: var(--text); }
.result-ranking { margin-top: .5rem; }
.result-ranking .rank-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .3rem .5rem; font-size: .85rem;
}
.result-ranking .rank-row:nth-child(1) { font-weight: 900; color: var(--game-accent); }
.result-ranking .rank-row .rank-pts { font-weight: 700; }
.next-btn { margin-top: .6rem; padding: .6rem 2rem; font-size: 1rem; border-radius: 999px; }

/* --- Score / Log --- */
.score-section { background: var(--surface); border-radius: var(--radius); padding: .5rem .8rem; box-shadow: var(--shadow); }
.score-section h4 { font-size: .7rem; color: var(--text-muted); margin-bottom: .3rem; text-transform: uppercase; font-weight: 700; }
.score-list { display: flex; flex-wrap: wrap; gap: .3rem .8rem; }
.score-item { font-size: .8rem; display: flex; gap: .3rem; align-items: center; }
.score-item .name { font-weight: 700; }
.score-item .pts { color: var(--game-accent); font-weight: 700; }

.log-section { background: var(--surface); border-radius: var(--radius); padding: .5rem .8rem; box-shadow: var(--shadow); }
.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.log-header h4 { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.clear-log-btn { background: var(--surface2); border: 2px solid var(--surface2); color: var(--text-muted); border-radius: 8px; padding: .15rem .5rem; font-size: .65rem; cursor: pointer; font-family: inherit; font-weight: 600; }
.log-entry { display: flex; justify-content: space-between; padding: .25rem 0; border-bottom: 1px solid var(--surface2); font-size: .75rem; }
.log-entry:last-child { border-bottom: none; }

/* --- Modal --- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(90,58,58,.3); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; max-width: 400px; width: 100%; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: var(--shadow-lg); }
.modal-box h3 { margin-bottom: .8rem; font-weight: 900; }
.modal-box ul { margin: 0 0 0 1.2rem; line-height: 1.8; font-size: .85rem; color: var(--text-muted); }
.modal-close { position: absolute; top: .5rem; right: .8rem; background: none; border: none; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; }

/* Shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.shake { animation: shake .4s ease; }

@media (max-width: 480px) {
  .parts-display { min-height: 170px; }
  .part-item { font-size: 2rem; }
  .assembled-display { font-size: 2.5rem; }
}
