* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

.nng-bg {
  min-height: 100vh;
  background-color: #ffb703;
  background-image: radial-gradient(circle, rgba(255,255,255,0.35) 2px, transparent 2px);
  background-size: 22px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.nng-container {
  background: #fff8ec;
  border-radius: 26px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 900px;
  overflow: hidden;
}

/* ---------- Header ---------- */
.nng-header {
  background: #ffca3a;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}
.nng-title { font-size: 19px; font-weight: 800; color: #4a3200; text-align: center; }
.nng-header-icon { font-size: 22px; }
.nng-home-link {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  background: #2ecc71; color: #fff; text-decoration: none; font-size: 12px; font-weight: 700;
  padding: 7px 13px; border-radius: 10px;
}

/* ---------- Loading / Warning ---------- */
.nng-loading, .nng-warning {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; gap: 14px; color: #7a5c00;
}
.nng-spinner {
  width: 36px; height: 36px; border: 4px solid #ffe6a1; border-top-color: #ff9f1c;
  border-radius: 50%; animation: nng-spin 0.8s linear infinite;
}
@keyframes nng-spin { to { transform: rotate(360deg); } }
.nng-warning-icon { font-size: 40px; }

/* ---------- Board ---------- */
.nng-board { padding: 20px 24px 26px; }
.nng-layout { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }

/* Word list panel */
.nng-wordlist {
  background: linear-gradient(160deg, #6a2c70, #4a1d52);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nng-word-pill {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  color: #4a3200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.2s;
}
.nng-word-pill.found { background: #d7f9e4; color: #1e8449; }
.nng-check-icon {
  width: 20px; height: 20px; border-radius: 50%; background: #2ecc71; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900;
  flex-shrink: 0; visibility: hidden;
}
.nng-word-pill.found .nng-check-icon { visibility: visible; }

/* Letter grid */
.nng-grid-wrap { display: flex; justify-content: center; }
.nng-grid {
  display: grid;
  gap: 2px;
  background: #dcdfe6;
  border: 2px solid #dcdfe6;
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
}
.nng-cell {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #2f3542;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nng-cell.selecting { background: #cfe3ff; }
.nng-cell.found { background: #b7f0cb; color: #1e8449; }

.nng-feedback {
  text-align: center; font-size: 14px; font-weight: 700; padding: 10px; border-radius: 10px; margin-top: 16px;
}
.nng-feedback-good { background: #e6f9ee; color: #1e8449; }
.nng-feedback-info { background: #fff4e0; color: #a1670a; }

.nng-actions { display: flex; justify-content: center; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.nng-btn {
  border: none; border-radius: 12px; padding: 12px 22px; font-size: 14px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: transform 0.15s;
  text-decoration: none;
}
.nng-btn:hover { transform: translateY(-2px); }
.nng-btn-reset { background: #ff9f1c; color: #fff; }
.nng-btn-submit { background: #2ecc71; color: #fff; }
.nng-btn-showanswer { background: #ffca3a; color: #4a3200; }
.nng-btn-home { background: #5b8def; color: #fff; }

/* ---------- Result screen ---------- */
.nng-result { text-align: center; padding: 50px 30px; }
.nng-result-icon { font-size: 56px; margin-bottom: 8px; }
.nng-result h2 { margin: 0 0 8px; color: #2f3542; }
.nng-result p { color: #6b6b6b; margin: 0 0 18px; }
.nng-result-score { font-size: 30px; font-weight: 800; color: #ff9f1c; margin-bottom: 24px; }
.nng-result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nng-layout { grid-template-columns: 1fr; }
  .nng-wordlist { flex-direction: row; flex-wrap: wrap; }
  .nng-word-pill { flex: 1 1 45%; font-size: 12px; padding: 8px 10px; }
}

@media (max-width: 480px) {
  .nng-bg { padding: 10px; }
  .nng-container { border-radius: 18px; }
  .nng-header { padding: 12px 14px; }
  .nng-title { font-size: 14px; padding-right: 50px; }
  .nng-home-link { right: 8px; padding: 5px 9px; font-size: 10px; }
  .nng-board { padding: 12px; }
  .nng-cell { font-size: 11px; }
  .nng-btn { width: 100%; justify-content: center; }
}
