/* ═══════════════════════════════════════════════════════════════════════════
   KN Games — Rebus Player  v1.2.0
   Stiluri scopate la .knrebus-wrap
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset + container ────────────────────────────────────────────────────── */

.knrebus-wrap {
  position: relative;    /* context de poziționare pentru modalul absolut */
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: transparent !important;
  box-shadow: none !important;
}
.knrebus-wrap *,
.knrebus-wrap *::before,
.knrebus-wrap *::after {
  box-sizing: border-box;
}

/* ── Fullscreen ──────────────────────────────────────────────────────────── */

.knrebus-wrap:-webkit-full-screen,
.knrebus-wrap:fullscreen {
  max-width: none !important;
  width: 100% !important;
  height: 100% !important;        /* ocupă tot viewport-ul */
  background: #ffffff !important;
  padding: 16px !important;
  box-sizing: border-box !important;
}

/* Grid-area ia tot spațiul rămas după toolbar; min-height din JS e anulat */
.knrebus-wrap:-webkit-full-screen .knrebus-grid-area,
.knrebus-wrap:fullscreen .knrebus-grid-area {
  flex: 1 1 0 !important;
  min-height: 0 !important;       /* anulează valoarea setată inline de JS */
  height: auto !important;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */

.knrebus-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 10px;
}

.knr-toolbar-left {
  display: flex;
  align-items: center;
  gap: 1px;
  background: rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 3px;
}

.knr-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: #0e5a8a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
  padding: 0;
  flex-shrink: 0;
}
.knr-btn:hover  { background: rgba(80,60,160,0.12); }

/* Tooltip întunecat — același stil ca la scorul anterior */
.knr-btn[data-tooltip] {
  position: relative;
}
.knr-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,30,.80);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity .18s ease;
}
.knr-btn[data-tooltip]:hover::after {
  opacity: 1;
}

/* Tooltip butonul ? — desktop: multiline din data-tooltip */
@media (hover: hover) {
  .knr-btn[data-action="help"]::after {
    white-space: pre-line !important;
    width: 260px !important;
    text-align: left !important;
    line-height: 1.6 !important;
    left: 0 !important;
    right: auto !important;
    transform: none !important;
  }
}
/* Tooltip butonul ? — mobile: scurt, din data-tooltip-short */
@media (hover: none) {
  .knr-btn[data-action="help"]::after {
    content: attr(data-tooltip-short) !important;
    white-space: nowrap !important;
    width: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}
.knr-btn:active { transform: scale(.92); }
.knr-btn svg    { pointer-events: none; }

.knr-tb-sep {
  width: 1px;
  height: 20px;
  background: rgba(0,0,0,0.12);
  margin: 0 3px;
  flex-shrink: 0;
}

/* ── Scor anterior (afișat la dreapta toolbarului, dacă există) ──────────── */

.knr-prev-score-display {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.35;
  text-align: right;
}
.knr-prev-score-display strong {
  color: #126CA4;
  font-weight: 700;
}
.knr-prev-score-display span {
  font-size: 11px;
  color: #9ca3af;
  display: block;
}

/* Tooltip cu ora — apare la hover pe tot blocul "Anterior" */
.knr-prev-score-display[data-time] {
  cursor: default;
  position: relative;
}
.knr-prev-score-display[data-time]::after {
  content: attr(data-time);
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: rgba(30,30,30,.80);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity .18s ease;
}
.knr-prev-score-display[data-time]:hover::after {
  opacity: 1;
}

/* ── Scor final ───────────────────────────────────────────────────────────── */

.knr-score-display {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px 5px 10px;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 9px;
  font-size: .82rem;
  color: #166534;
  animation: knrFadeIn .4s ease;
}
.knr-score-label { font-weight: 600; }
.knr-score-val   { font-size: 1.1rem; font-weight: 800; color: #15803d; }
.knr-score-sub   { font-size: .7rem; color: #4ade80; }
.knr-score-notice { font-size: .7rem; color: #6b7280; margin-left: 2px; }

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

/* ── Zona grilei ──────────────────────────────────────────────────────────── */

.knrebus-grid-area {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 320px;
  background: transparent !important;
}

.knrebus-grid-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  /* transform-ul e setat dinamic prin JS */
}

/* ════════════════════════════════════════════════════════════════════════════
   CELULE — gri foarte deschis, text negru, accent albastru #126CA4
   ════════════════════════════════════════════════════════════════════════════ */

.knr-cell {
  position: absolute;

  /* ── Reset complet cu !important ─────────────────────────────────────────
     Temele WP aplică deseori font-size/padding/border/background pe <input>.
  ── */
  -webkit-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  padding: 0 !important;
  outline: none !important;
  box-sizing: border-box !important;

  /* Aspect de bază — gri foarte deschis */
  border: 1.5px solid #d8d8d8 !important;
  border-radius: 6px !important;
  background: #f2f2f2 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.85);

  /* Tipografie — 30% mai mare: 18px × 1.3 ≈ 23px */
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
  font-size: 23px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  text-align: center !important;
  text-transform: uppercase !important;
  letter-spacing: 0 !important;
  color: #1a1a1a !important;
  caret-color: transparent !important;

  cursor: text;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;

  transition: background .12s, border-color .12s, box-shadow .12s;
  animation: knrCellIn .20s cubic-bezier(.34,1.56,.64,1) backwards;
}
.knr-cell:hover:not(.knr-locked):not(.knr-hinted):not(.knr-active):not(.knr-done):not(.knr-word-sel) {
  border-color: #b0b0b0;
  background: #e8e8e8 !important;
}
.knr-cell.knr-word-sel:hover {
  background: #b8d8ef !important;
  border-color: #62a8cc !important;
}

@keyframes knrCellIn {
  from { opacity: 0; transform: scale(.3); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Selecție cuvânt — albastru foarte deschis derivat din #126CA4 ─────────── */

.knr-cell.knr-word-sel {
  background: #d0e9f8 !important;
  border-color: #7ab8d8 !important;
  box-shadow: 0 1px 4px rgba(18,108,164,0.12);
}

/* ── Celulă activă — albastru #126CA4 ────────────────────────────────────── */

.knr-cell.knr-active {
  background: #126CA4 !important;
  border-color: #0e5a8a !important;
  box-shadow: 0 0 0 2.5px rgba(18,108,164,0.28) !important;
  color: #fff !important;
}

/* ── Verificare: corect / greșit ─────────────────────────────────────────── */

.knr-cell.knr-correct {
  background: #16a34a !important;
  border-color: #15803d !important;
  color: #fff !important;
  box-shadow: 0 1px 4px rgba(22,163,74,0.28) !important;
}
.knr-cell.knr-wrong {
  background: #dc2626 !important;
  border-color: #b91c1c !important;
  color: #fff !important;
  box-shadow: 0 1px 4px rgba(220,38,38,0.28) !important;
  animation: knrShake .28s ease;
}

/* ── Blocat (auto-lock easy mode) ────────────────────────────────────────── */

.knr-cell.knr-locked {
  background: #22c55e !important;
  border-color: #16a34a !important;
  color: #fff !important;
  box-shadow: 0 1px 4px rgba(34,197,94,0.25) !important;
  cursor: default !important;
  pointer-events: none;
}

/* ── Hint (dezvăluit cu Reveal) ──────────────────────────────────────────── */

.knr-cell.knr-hinted {
  background: #0284c7 !important;
  border-color: #0369a1 !important;
  color: #fff !important;
  box-shadow: 0 1px 4px rgba(2,132,199,0.28) !important;
  cursor: default !important;
  pointer-events: none;
}

@keyframes knrShake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-5px); }
  75%     { transform: translateX( 5px); }
}

/* ── Stare finalizat (joc terminat) ──────────────────────────────────────── */

/* Celulele revin la gri normal, nu mai pot fi editate, fără hover */
.knr-cell.knr-done {
  background: #f2f2f2 !important;
  border-color: #d8d8d8 !important;
  color: #1a1a1a !important;
  box-shadow: none !important;
  cursor: default !important;
  pointer-events: none !important;
  animation: none !important;
}

/* ── Buton dezactivat (după terminare joc) ───────────────────────────────── */

.knr-btn:disabled,
.knr-btn[disabled] {
  opacity: 0.28 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* ── Felicitare în modalul de definiții ──────────────────────────────────── */

.knr-deflist-congrats {
  display: none;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.knr-modal-congrats {
  text-align: center;
  padding: 4px 0 6px;
}
.knr-modal-congrats-emoji {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
}
.knr-modal-congrats-title {
  font-size: 19px !important;
  font-weight: 900 !important;
  color: #0e5a8a !important;
  letter-spacing: 1.5px !important;
  margin: 0 0 10px !important;
  padding: 0 !important;
  border: none !important;
  line-height: 1.2 !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
}
.knr-modal-congrats-score {
  font-size: 24px !important;
  font-weight: 800 !important;
  color: #126CA4 !important;
  margin: 0 0 5px !important;
  padding: 0 !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
}
.knr-modal-congrats-detail {
  font-size: 13px !important;
  color: #6b7280 !important;
  line-height: 1.55 !important;
  margin: 0 0 14px !important;
  padding: 0 !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
}

/* Buton restart */
.knr-restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: #126CA4;
  color: #fff !important;
  border: none;
  border-radius: 8px;
  font-size: 14px !important;
  font-weight: 700 !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none !important;
}
.knr-restart-btn:hover  { background: #0e5a8a; color: #fff !important; }
.knr-restart-btn:active { transform: scale(.94); }

/* ── Etichete numerice externe ────────────────────────────────────────────── */

.knr-num-label {
  position: absolute;
  display: flex;
  font-size: 13px;
  font-weight: 400;
  color: #555;
  pointer-events: none;
  line-height: 1;
  letter-spacing: 0;
}

/* ── Banner ajutor (înlocuiește modalul Help) ─────────────────────────────── */

.knr-help-banner {
  display: none;
  position: relative;
  margin: 0 0 10px;
  padding: 10px 14px;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
  animation: knrBannerIn .2s ease;
}
@keyframes knrBannerIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Fără spații între propoziții — text continuu */
.knr-help-banner p {
  display: inline;
  margin: 0 !important;
  padding: 0 !important;
}
.knr-help-banner p::after { content: ' '; }

/* ── Buton X (înapoi) ────────────────────────────────────────────────────── */

.knr-btn-back:hover { background: rgba(220,38,38,.12) !important; color: #dc2626 !important; }

/* ── Modal lista definițiilor ────────────────────────────────────────────── */

.knrebus-deflist-modal {
  position: absolute;
  z-index: 101;
  top: 60px;
  left: 20px;
  width: 320px;
  height: 28vh;        /* jumătate din viewport */
  min-width: 220px;
  min-height: 120px;
  max-height: 85vh;
  background: #fff;
  border-radius: 13px;
  box-shadow:
    0 4px 28px rgba(50,30,140,.13),
    0 0 0 1px rgba(100,80,220,.09);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.knr-deflist-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 9px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 13px 13px 0 0;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}
.knr-deflist-hdr:active { cursor: grabbing; }

.knr-deflist-title {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #126CA4 !important;
  letter-spacing: .4px;
  text-transform: uppercase;
}


.knr-deflist-body {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1 1 0;
}

.knr-dli {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background .12s;
  line-height: 1.45;
}
/* Fără selecție text în deflist */
.knrebus-deflist-modal {
  user-select: none;
  -webkit-user-select: none;
}

/* Handle redimensionare — doar pe desktop */
.knr-resize-handle {
  flex-shrink: 0;
  height: 22px;
  cursor: se-resize;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 0 0 13px 13px;
  background: #f0f4f8;
  border-top: 1px solid #e2e8f0;
  position: relative;
}
.knr-rsh-icon {
  position: absolute;
  right: 6px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
}
/* Ascunde handle-ul pe mobil (touch) */
@media (hover: none) {
  .knr-resize-handle { display: none; }
}

.knr-dli:hover          { background: #f0f7fd; }
.knr-dli.knr-dli-active { background: #dbeeff; }

.knr-dli-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 1px 6px;
  background: #126CA4;
  color: #fff !important;
  border-radius: 10px;
  font-size: 12px !important;
  font-weight: 700 !important;
  flex-shrink: 0;
  white-space: nowrap;
}

.knr-dli-text {
  font-size: 13px !important;
  color: #374151 !important;
  line-height: 1.5 !important;
}
.knr-dli-text strong { color: #111827 !important; font-weight: 600 !important; }
.knr-dli-text em     { color: #9ca3af !important; }

/* ── Eroare ───────────────────────────────────────────────────────────────── */

.knrebus-error {
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #991b1b;
  font-size: .87rem;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .knrebus-def-modal {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 12px;
    border-radius: 10px;
  }
  .knrebus-grid-area { min-height: 240px; }
}
