/* 타일 상태: 정답=초록, 위치 다름=노랑, 없음=회색 */
:root {
  --hit: #3a9d5d;
  --hit-text: #ffffff;
  --near: #d4a72c;
  --near-text: #ffffff;
  --miss: #8e8e93;
  --miss-text: #ffffff;
  --key: #e8e8ed;
  --key-miss: #48484a;      /* 쓴 글자(없음): 확실히 어둡게 */
  --key-miss-text: #8e8e93;
}
@media (prefers-color-scheme: dark) {
  :root {
    --hit: #3f9e5f;
    --near: #c49a26;
    --miss: #3a3a3c;
    --key: #48484a;         /* 다크모드: 안 쓴 키는 밝게 */
    --key-miss: #141415;    /* 쓴 키는 배경에 묻히게 */
    --key-miss-text: #48484a;
  }
}

.header-actions { display: flex; align-items: center; gap: 4px; }

.game {
  max-width: 500px; margin: 0 auto; padding: 20px 10px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  min-height: calc(100vh - 52px);
}
.title-row { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title-row h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; }


/* 보드 */
.board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; width: min(330px, 88vw); }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.row.shake { animation: shake .4s; }
.tile {
  aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center;
  font-size: clamp(1.4rem, 7vw, 1.9rem); font-weight: 600; text-transform: uppercase;
  background: var(--bg); border: 1.5px solid var(--line); color: var(--text);
  user-select: none;
}
.tile.filled { border-color: var(--muted); animation: pop .12s; }
.tile.hit  { background: var(--hit);  border-color: var(--hit);  color: var(--hit-text); }
.tile.near { background: var(--near); border-color: var(--near); color: var(--near-text); }
.tile.miss { background: var(--miss); border-color: var(--miss); color: var(--miss-text); }
.tile.reveal { animation: flip .5s cubic-bezier(.2,.8,.2,1) both; }
.row.win .tile { animation: bounce .5s ease both; }
.row.win .tile:nth-child(2) { animation-delay: .06s; }
.row.win .tile:nth-child(3) { animation-delay: .12s; }
.row.win .tile:nth-child(4) { animation-delay: .18s; }
.row.win .tile:nth-child(5) { animation-delay: .24s; }

@keyframes pop { 50% { transform: scale(1.06); } }
@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: none; } }
@keyframes bounce { 40% { transform: translateY(-10px); } 70% { transform: translateY(2px); } }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

/* 키보드 */
.keyboard { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1; max-width: 44px; height: 54px; border: 0; border-radius: 8px;
  background: var(--key); color: var(--text); font: inherit; font-weight: 500; font-size: 1.05rem;
  text-transform: uppercase; cursor: pointer; touch-action: manipulation;
  transition: background .2s, color .2s;
}
.key.wide { max-width: 68px; flex: 1.5; font-size: .75rem; font-weight: 600; }
.key:active { opacity: .6; }
.key.hit  { background: var(--hit);  color: var(--hit-text); }
.key.near { background: var(--near); color: var(--near-text); }
.key.miss { background: var(--key-miss); color: var(--key-miss-text); }

/* 토스트 */
.toast {
  position: fixed; top: 72px; left: 50%; transform: translate(-50%, -6px);
  background: var(--ink); color: var(--on-ink); font-size: .9rem; font-weight: 500;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 다이얼로그 */
.dlg {
  background: var(--bg); color: var(--text); border: 0;
  border-radius: 20px; padding: 28px; width: min(400px, 92vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
@media (prefers-color-scheme: dark) { .dlg { background: #1c1c1e; } }
.dlg::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(6px); }
.dlg h2 { margin: 0 0 12px; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.dlg h3 { font-size: .8rem; font-weight: 600; margin: 24px 0 10px; color: var(--muted); }
.dlg p { line-height: 1.6; font-size: .95rem; }
.muted { color: var(--muted); font-size: .88rem; }
.legend { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; font-size: .92rem; }
.legend li { display: flex; align-items: center; gap: 12px; }
.legend .tile { width: 34px; font-size: .95rem; border-radius: 8px; }
.result-msg { font-weight: 600; }
.result-msg:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 6px; }
.stats strong { display: block; font-size: 1.8rem; font-weight: 600; letter-spacing: -0.02em; }
.stats span { font-size: .72rem; color: var(--muted); }
.dist { display: grid; gap: 5px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.dist-row > span { width: 10px; color: var(--muted); }
.dist-bar { background: var(--key); padding: 3px 8px; border-radius: 5px; text-align: right; min-width: 26px; font-weight: 600; }
.dist-bar.now { background: var(--hit); color: var(--hit-text); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }
.dlg-actions form { margin: 0; }

@media (max-width: 380px) {
  .key { height: 48px; font-size: .95rem; }
  .kb-row { gap: 4px; }
}
