/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
  background: #f5f0e8;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 12px 8px 24px;
}

/* ===== App Container ===== */
#app {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== Header ===== */
header {
  text-align: center;
  padding: 4px 0 6px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 900;
  color: #333;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* ステージ・★・♥ を同じ行・同じフォントに揃える */
#header-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo',
               'Segoe UI Symbol', 'Apple Symbols', sans-serif;
}

#stage-label {
  font-size: 1.0rem;
  font-weight: bold;
  color: #888;
  min-width: 72px;
}

/* ★ と ♥ のフォント・サイズ・レンダリングを統一 */
#diff-stars,
#lives {
  font-size: 1.0rem;
  letter-spacing: 2px;
  font-variant-emoji: text;
  -webkit-text-stroke: 0;
}

#diff-stars {
  color: #f0a030;
}

#lives {
  color: #e05555;
  min-width: 72px;
  text-align: right;
}

/* ===== Score ===== */
#score-area {
  text-align: center;
  font-size: 1.6rem;
  font-weight: bold;
  color: #444;
  line-height: 1;
}

.pt-label {
  font-size: 0.9rem;
  color: #888;
  margin-left: 2px;
}

#combo-label {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #f07820;
  vertical-align: middle;
}

/* ===== Message ===== */
.message {
  text-align: center;
  font-weight: bold;
  font-size: 0.95rem;
  min-height: 1.5em;
  transition: opacity 0.4s;
  letter-spacing: 0.05em;
}
.message.success { color: #2a9e70; }
.message.near    { color: #e08020; }
.message.wrong   { color: #d83030; }
.message.info    { color: #6688aa; }

/* ===== Selected Display ===== */
#selected-display {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.sel-slot {
  width: 56px;
  height: 56px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: #555;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.sel-slot.filled {
  border: 2px solid #3aaa7a;
  background: #edfaf3;
  color: #2a8860;
}

/* ===== Grid ===== */
#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tile {
  aspect-ratio: 1;
  background: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.7rem;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12), 0 1px 0 rgba(0,0,0,0.08);
  transition: background 0.12s, transform 0.12s, box-shadow 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.tile:hover:not(.used):not(.selected) {
  background: #f0f8ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.tile.selected {
  background: #3aaa7a;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40,180,110,0.35);
}

.tile.used {
  background: #e8e8e8;
  color: #bbb;
  cursor: default;
  box-shadow: none;
  transform: none;
}

/* ===== Hint ===== */
#hint-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#hint-btn {
  padding: 5px 16px;
  background: #f5f0e8;
  color: #998870;
  border: 1px solid #e0d8cc;
  border-radius: 16px;
  font-size: 1.0rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

#hint-btn:hover:not(:disabled) {
  background: #ede6da;
  border-color: #d0c8b8;
  color: #776650;
}

#hint-btn:disabled,
#hint-btn.used {
  color: #ccc;
  border-color: #e8e8e8;
  background: #f8f8f8;
  cursor: default;
}

#hint-text {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.5;
  text-align: center;
}

/* ===== Found Idioms ===== */
#found-section {
  min-height: 42px;
}

#found-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.found-item {
  background: #3aaa7a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(40,160,100,0.25);
  animation: popIn 0.3s ease-out;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.found-word {
  font-size: 1.05rem;
  font-weight: bold;
  letter-spacing: 4px;
}

.found-reading {
  font-size: 0.72rem;
  opacity: 0.85;
  letter-spacing: 0.05em;
  font-weight: normal;
}

.found-meaning {
  font-size: 0.8rem;
  opacity: 0.95;
  letter-spacing: 0.02em;
  font-weight: normal;
  line-height: 1.5;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ===== Stage Clear Bar ===== */
#stage-clear-bar {
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  animation: slideUp 0.35s ease-out;
}

#next-stage-btn,
#retire-btn {
  padding: 10px 28px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s, transform 0.1s;
}

#next-stage-btn {
  background: #3aaa7a;
  color: #fff;
}

#next-stage-btn:hover {
  background: #2e9065;
  transform: translateY(-1px);
}

#retire-btn {
  background: #c3c3c3;
  color: #333;
}

#retire-btn:hover {
  background: #adadad;
  transform: translateY(-1px);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding-top: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
}

.footer-sep {
  color: #ccc;
  font-size: 0.75rem;
  margin: 0 8px;
}

#info-trigger,
#records-trigger {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.0rem;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s;
}

#info-trigger:hover,
#records-trigger:hover {
  color: #888;
}

/* ===== Overlays (shared) ===== */
#overlay,
#info-dialog,
#records-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 16px;
}

/* ===== Game Over Overlay ===== */
#overlay-card {
  background: #fff;
  border-radius: 18px;
  padding: 32px 28px 28px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

#overlay-title {
  font-size: 1.5rem;
  font-weight: 900;
  margin-bottom: 16px;
  color: #333;
}

#overlay-body {
  margin-bottom: 20px;
}

.go-answer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

/* ゲームオーバー内コンテンツ */
.go-new-record {
  color: #f07820;
  font-weight: bold;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.go-title-label {
  font-size: 0.68rem;
  color: #aaa;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.go-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: #2a8860;
  margin-bottom: 14px;
  line-height: 1.3;
}

.go-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.go-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 4px;
}

.go-stat-row span {
  font-size: 0.82rem;
  color: #888;
}

.go-stat-row strong {
  font-size: 0.92rem;
  color: #333;
}

/* 次の称号プログレス */
.go-next {
  background: #faf8f4;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.go-next-label {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 6px;
}

.go-next-label.go-max {
  color: #f0a030;
  font-weight: bold;
}

.go-progress {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.go-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3aaa7a, #50c89a);
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.go-next-rem {
  font-size: 0.7rem;
  color: #aaa;
}

.go-divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 0 0 14px;
}

.go-records {
  background: #f8f8f8;
  border-radius: 10px;
  padding: 12px 16px;
}

.go-record-label {
  font-size: 0.68rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.go-record-score {
  font-size: 1.15rem;
  font-weight: bold;
  color: #333;
}

.go-record-title {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 4px;
}

.go-record-games {
  font-size: 0.72rem;
  color: #bbb;
}

#overlay-btn {
  padding: 12px 36px;
  background: #3aaa7a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.05em;
}

#overlay-btn:hover {
  background: #2e9065;
  transform: translateY(-1px);
}

/* ===== Info Dialog ===== */
#info-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

#info-card h2 {
  font-size: 1.3rem;
  font-weight: 900;
  color: #333;
  margin-bottom: 16px;
  text-align: center;
}

#info-card h3 {
  font-size: 0.85rem;
  font-weight: bold;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
}

#info-card ul {
  padding-left: 18px;
  color: #444;
  font-size: 0.88rem;
  line-height: 2;
}

#info-card p {
  color: #555;
  font-size: 0.88rem;
  line-height: 1.8;
}

#info-card a {
  color: #3aaa7a;
  text-decoration: none;
}

#info-card a:hover {
  text-decoration: underline;
}

#info-close {
  display: block;
  margin: 20px auto 0;
  padding: 9px 28px;
  background: #bbb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

#info-close:hover {
  background: #999;
}

/* ===== Records Dialog ===== */
#records-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

#records-card h2 {
  font-size: 1.3rem;
  font-weight: 900;
  color: #333;
  margin-bottom: 16px;
  text-align: center;
}

.rec-stats {
  margin-bottom: 16px;
}

.rec-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 2px;
  border-bottom: 1px solid #f0f0f0;
}

.rec-row span {
  font-size: 0.85rem;
  color: #888;
}

.rec-row strong {
  font-size: 0.95rem;
  color: #333;
}

.rec-title-section {
  margin-top: 12px;
}

.rec-title-header {
  font-size: 0.78rem;
  font-weight: bold;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
}

.rec-title-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 4px;
  font-size: 0.8rem;
  color: #ccc;
  border-radius: 4px;
}

.rec-title-row.achieved {
  color: #555;
  font-weight: 600;
}

.rec-title-row.current {
  color: #2a8860;
  font-weight: 700;
  background: #edfaf3;
}

.rec-title-name {
  flex: 1;
}

.rec-title-score {
  text-align: right;
  min-width: 70px;
}

#records-close {
  display: block;
  margin: 20px auto 0;
  padding: 9px 28px;
  background: #bbb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

#records-close:hover {
  background: #999;
}

#records-reset {
  display: block;
  margin: 24px auto 0;
  padding: 8px 24px;
  border-radius: 8px;
  border: 1px solid #d83030;
  background: #fff;
  color: #d83030;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

#records-reset:hover { opacity: 1; }

/* ===== Responsive: wider screens ===== */
@media (min-width: 440px) {
  .tile { font-size: 1.9rem; }
}
