/* ===== Moji-Awase (もじあわせ) ===== */
:root {
  --game-accent: #C5B8E0;
  --game-accent-pink: #FBD4DC;
  --game-accent-yellow: #FBE9A0;
}

/* --- Top Bar --- */
.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); transition: color .2s; }
.top-bar .title a:hover { color: var(--primary); }
.top-bar .title span { color: var(--text); font-weight: 900; }
.top-bar-actions { display: flex; gap: .4rem; align-items: center; }
.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;
  transition: border-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--game-accent); color: #5A3A3A; }

/* --- Help 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; transition: color .2s;
}
.modal-close:hover { color: var(--primary); }

/* --- Game Page --- */
.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;
}
.start-btn {
  margin-top: .8rem; width: 100%; padding: .7rem; font-size: 1.1rem;
  border-radius: 999px;
}

/* --- Phase Section --- */
.phase-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.2rem 1rem; box-shadow: var(--shadow);
}
.round-counter { font-size: .8rem; color: var(--text-muted); font-weight: 600; }

/* --- Scoreboard --- */
.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; letter-spacing: .05em; font-weight: 700; }
.score-list { display: flex; flex-direction: column; gap: .2rem; }
.score-row { display: flex; justify-content: space-between; font-size: .8rem; padding: .15rem 0; }
.score-row.top { font-weight: 700; }

/* --- Log --- */
.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; letter-spacing: .05em; 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; transition: border-color .2s, color .2s;
}
.clear-log-btn:hover { border-color: var(--primary); color: var(--primary); }
.log-entry {
  display: flex; align-items: center; gap: .4rem;
  padding: .25rem 0; border-bottom: 1px solid var(--surface2); font-size: .75rem;
}
.log-entry:last-child { border-bottom: none; }
.log-status { flex-shrink: 0; }
.log-detail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-time { flex-shrink: 0; color: var(--text-muted); font-size: .65rem; }

/* Turn info */
.turn-info {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .8rem;
}
.pile-info {
  font-size: .75rem; color: var(--text-muted);
  background: var(--surface); padding: .3rem .6rem; border-radius: 8px;
}

/* Drawn tile highlight */
.drawn-tile-area {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: .8rem;
  animation: drawnPulse .6s ease;
}
.drawn-label {
  font-size: .7rem; color: var(--text-muted); margin-bottom: .3rem;
}
@keyframes drawnPulse {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Tile grid (hand) */
.hand-area { margin-bottom: 1rem; }
.hand-label {
  font-size: .7rem; color: var(--text-muted); margin-bottom: .4rem;
}
.tile-grid {
  display: flex; flex-wrap: nowrap; gap: 4px;
  justify-content: center;
}

/* Individual tile */
.tile {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 700;
  background: var(--surface);
  border: 2px solid #e0d8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 2px 6px rgba(45,32,64,.08);
}
.tile:active { transform: scale(0.92); }
.tile.selected {
  border-color: var(--game-accent-pink);
  background: var(--game-accent-pink);
  box-shadow: 0 0 0 3px rgba(251,212,220,.35);
  transform: scale(1.05);
}
.tile.tile-drawn {
  width: 46px; height: 46px; font-size: 1.3rem;
  border-color: var(--game-accent-yellow);
  background: var(--game-accent-yellow);
  box-shadow: 0 0 12px rgba(251,233,160,.5);
}
.tile.discard-mode {
  border-color: #f87171;
  animation: discardPulse 1s infinite;
}
@keyframes discardPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,.3); }
  50% { box-shadow: 0 0 0 6px rgba(248,113,113,.1); }
}
.tile.placed {
  opacity: .3; pointer-events: none;
}

/* Word zones */
.word-zones {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 1rem;
}
.word-zone {
  background: var(--surface);
  border: 2px dashed #d4c8e8;
  border-radius: 12px;
  padding: .5rem;
  display: flex; align-items: center; gap: 8px;
}
.word-zone.zone-complete {
  border-color: #34d399;
  border-style: solid;
  background: #ecfdf5;
}
.zone-label {
  font-size: .65rem; font-weight: 700; color: var(--text-muted);
  min-width: 36px; text-align: center;
}
.zone-slots {
  display: flex; gap: 4px; flex: 1;
}
.zone-slot {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 700;
  background: #f8f5ff;
  border: 2px dashed #d4c8e8;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s ease;
}
.zone-slot.filled {
  background: var(--surface);
  border: 2px solid var(--secondary);
  border-style: solid;
}
.zone-slot:hover, .zone-slot:active {
  border-color: var(--primary);
}

/* Action buttons */
.action-row {
  display: flex; gap: 8px; justify-content: center;
  margin-bottom: .8rem;
}
.action-row .btn { flex: 1; max-width: 180px; }

/* Discard area */
.discard-area {
  padding: .6rem; border-radius: 12px;
  background: #fef2f2; border: 1px solid #fecaca;
  text-align: center;
}
.discard-label {
  font-size: .65rem; color: #dc2626; font-weight: 700;
  margin-bottom: .3rem;
}
.discard-msg {
  font-size: .75rem; color: #b91c1c;
}

/* Discard pile */
.discard-pile-section {
  padding: .6rem 1rem;
}
.discard-pile-header h4 {
  font-size: .75rem; color: var(--text-muted); margin-bottom: .4rem;
}
.discard-pile-grid {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.discard-pile-grid .tile {
  width: 32px; height: 32px;
  font-size: .9rem;
  border-color: #e5e7eb;
  background: #f9fafb;
  cursor: default;
  opacity: .7;
}

/* Validation */
.validation-words {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 1rem;
}
.validation-word {
  background: var(--surface);
  border-radius: 12px;
  padding: .8rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.validation-word-text {
  font-size: 1.6rem; font-weight: 900;
  letter-spacing: .1em;
  margin-bottom: .5rem;
}
.validation-word-tiles {
  display: flex; justify-content: center; gap: 4px;
  margin-bottom: .6rem;
}
.validation-word-tiles .tile {
  width: 38px; height: 38px; font-size: 1.1rem;
  cursor: default;
}
.vote-btns {
  display: flex; gap: 8px; justify-content: center;
}
.vote-btn {
  padding: .4rem 1.2rem;
  border-radius: 20px;
  font-size: .85rem; font-weight: 700;
  border: 2px solid;
  cursor: pointer;
  transition: all .15s;
}
.vote-btn.approve {
  color: #059669; border-color: #059669; background: #ecfdf5;
}
.vote-btn.approve:hover, .vote-btn.approve.active {
  background: #059669; color: #fff;
}
.vote-btn.reject {
  color: #dc2626; border-color: #dc2626; background: #fef2f2;
}
.vote-btn.reject:hover, .vote-btn.reject.active {
  background: #dc2626; color: #fff;
}
.validation-word.auto-approved {
  border: 2px solid #34d399;
  background: #ecfdf5;
}
.wiki-badge {
  font-size: .75rem; font-weight: 700; color: #059669;
  margin-top: .3rem;
}
.vote-area {
  text-align: center;
}
.vote-submit {
  margin-top: .8rem;
}

/* Result */
.result-section { text-align: center; }
.result-icon { font-size: 3rem; margin-bottom: .5rem; }
.result-msg { font-size: 1rem; font-weight: 700; margin-bottom: .8rem; }

/* Responsive */
@media (max-width: 360px) {
  .tile { width: 34px; height: 34px; font-size: 1rem; }
  .zone-slot { width: 34px; height: 34px; font-size: 1rem; }
  .tile.tile-drawn { width: 42px; height: 42px; font-size: 1.2rem; }
  .tile-grid { gap: 3px; }
}
