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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0d0d1a;
  color: #e0e0f0;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }
#screen-win.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== MENU ===== */
header {
  text-align: center;
  padding: 24px 0 12px;
}
h1 {
  font-size: 2.4rem;
  color: #a29bfe;
  letter-spacing: 2px;
}
.sub {
  color: #74b9ff;
  margin-top: 6px;
  font-size: 1rem;
}

/* Progress bar */
.prog-wrap { padding: 8px 0 14px; text-align: center; }
.prog-bar {
  height: 8px;
  background: #1a1a35;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.prog-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #6c5ce7, #a29bfe);
  transition: width .4s ease;
  border-radius: 4px;
}
#progress-text { font-size: .82rem; color: #888899; }

/* Difficulty filter */
#diff-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 16px;
}
.df-btn {
  background: #14142a;
  border: 1px solid #2d2d5e;
  color: #9999bb;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .82rem;
  transition: all .2s;
}
.df-btn:hover, .df-btn.active {
  background: #2d2d5e;
  color: #e0e0f0;
  border-color: #6c5ce7;
}

/* Level grid */
#level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 7px;
}

.lvl-btn {
  background: #14142a;
  border: 2px solid #2d2d5e;
  border-radius: 10px;
  padding: 8px 4px 7px;
  text-align: center;
  transition: all .18s;
  user-select: none;
}
.lvl-btn:not(.locked) { cursor: pointer; }
.lvl-btn:not(.locked):hover {
  border-color: #a29bfe;
  background: #1e1e40;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(108,92,231,.25);
}
.lvl-btn.locked  { opacity: .32; cursor: not-allowed; }
.lvl-btn.done    { background: #0a3d2b; border-color: #00b894; }
.lvl-btn .lnum   { display: block; font-size: 1.1rem; font-weight: 700; color: #e0e0f0; }
.lvl-btn.done .lnum { color: #55efc4; }
.lvl-btn .lsize  { display: block; font-size: .68rem; color: #7777aa; margin-top: 2px; }
.lvl-btn .ldiff  { display: block; font-size: .66rem; margin-top: 1px; }

/* ===== GAME SCREEN ===== */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 12px;
  border-bottom: 1px solid #1e1e40;
  margin-bottom: 10px;
}

#btn-back {
  background: #1e1e40;
  border: 1px solid #2d2d5e;
  color: #c0c0e0;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: .88rem;
  transition: background .2s;
}
#btn-back:hover { background: #6c5ce7; color: #fff; border-color: #6c5ce7; }

#level-info { text-align: center; }
#level-title { display: block; font-size: 1.15rem; font-weight: 700; color: #a29bfe; }
#level-meta  { color: #74b9ff; font-size: .78rem; }

#timer {
  font-size: .95rem;
  color: #fdcb6e;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}

/* Board */
#board-wrap {
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 6px 0;
  min-height: 200px;
}

/* ===== NONOGRAM TABLE ===== */
.ngram { border-collapse: collapse; }
.ngram td { padding: 0; }

.corner { min-width: 12px; }

.clue {
  font-size: .76rem;
  color: #7777aa;
  text-align: center;
  vertical-align: middle;
  line-height: 1.5;
  user-select: none;
  transition: color .15s;
}
.clue.rcl {
  text-align: right;
  padding-right: 5px;
  white-space: nowrap;
  min-width: 20px;
}
.clue.ccl {
  padding-bottom: 3px;
  vertical-align: bottom;
}
.clue.done  { color: #00b894; font-weight: 700; }
.clue.wrong { color: #e17055; }

/* Game cells */
.gc {
  width:  var(--cs, 34px);
  height: var(--cs, 34px);
  border: 1px solid #1e1e40;
  background: #12122a;
  cursor: pointer;
  transition: background .07s, border-color .07s;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.gc:hover             { background: #1e1e40; border-color: #6c5ce7; }
.gc.filled            { background: #6c5ce7; border-color: #9580ff; }
.gc.filled:hover      { background: #5a4fd4; }
.gc.marked            { background: #14142a; border-color: #2d2d5e; }
.gc.marked::after {
  content: '✕';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #44446a; font-size: .72rem; pointer-events: none;
}
.gc.win-flash {
  background: #00b894 !important;
  border-color: #00cec9 !important;
  animation: cflash .35s ease;
}
@keyframes cflash {
  0%  { background: #fff; }
  100%{ background: #00b894; }
}

/* Thick separators every 5 cells */
.gc.tl { border-left: 2px solid #4a4a7a; }
.gc.tt { border-top:  2px solid #4a4a7a; }

/* ===== CTRL BAR ===== */
#ctrl-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px 14px;
  background: #14142a;
  border-radius: 10px;
  margin-top: 10px;
  font-size: .8rem;
  color: #7777aa;
}
.hint { user-select: none; }

#btn-reset {
  background: #1e1e40;
  border: 1px solid #2d2d5e;
  color: #c0c0e0;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: .83rem;
  transition: background .2s;
  margin-left: auto;
}
#btn-reset:hover { background: #e17055; color: #fff; border-color: #e17055; }

/* ===== WIN SCREEN ===== */
#win-box {
  text-align: center;
  padding: 40px 28px;
  background: #14142a;
  border: 2px solid #2d2d5e;
  border-radius: 20px;
  max-width: 380px;
  width: 100%;
}
#win-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 14px;
  animation: bob .55s ease-in-out infinite alternate;
}
@keyframes bob {
  from { transform: scale(1) rotate(-4deg); }
  to   { transform: scale(1.15) rotate(4deg); }
}
#win-box h2 { font-size: 2rem; color: #a29bfe; margin-bottom: 10px; }
#win-time   { color: #fdcb6e; font-size: 1.05rem; margin-bottom: 6px; }
#win-stars  { font-size: 1.7rem; margin-bottom: 24px; letter-spacing: 4px; }

#win-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

#btn-next, #btn-to-menu {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  font-size: .92rem;
  transition: transform .15s, background .2s;
}
#btn-next     { background: #6c5ce7; color: #fff; }
#btn-next:hover { background: #a29bfe; transform: scale(1.05); }
#btn-to-menu  { background: #1e1e40; color: #c0c0e0; border: 1px solid #2d2d5e; }
#btn-to-menu:hover { background: #2d2d5e; }

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  h1 { font-size: 1.8rem; }
  #level-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; }
}
