:root {
  --tile: 32px;
  --gap: 3px;
  --bg: #0f1115;
  --tile-bg: #121213;
  --tile-border: #3a3a3c;
  --tile-text: #fff;
  --ok: #34d399;
  --bad: #ef4444;
  --accent: #6366f1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: #e9e9e9;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.header {
  padding: 0.5rem 1rem 0.25rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo {
  height: 30px;
  max-width: 90%;
  object-fit: contain;
}

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 1.25rem 0.5rem 1rem;
  gap: 0.5rem;
}

.chain {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  justify-content: center;
}

.row {
  display: flex;
  gap: var(--gap);
  transition: transform 0.2s ease;
  justify-content: center;
}

.tile {
  width: var(--tile);
  height: var(--tile);
  display: grid;
  place-items: center;
  border: 2px solid var(--tile-border);
  border-radius: 3px;
  background: var(--tile-bg);
  color: var(--tile-text);
  font-weight: 700;
  font-size: calc(var(--tile) * 0.5);
  text-transform: uppercase;
  transition: all 0.3s ease;
}

.tile.filled { animation: pop 0.2s ease; border-color: var(--accent); background: #1a1b2e; }
.tile.start  { border-color: var(--ok); background: rgba(52,211,153,0.1); }
.tile.success { border-color: var(--ok); background: rgba(52,211,153,0.2); animation: pulse 0.5s ease; }
.tile.failure { border-color: var(--bad); background: rgba(239,68,68,0.2); animation: shake 0.5s ease; }

@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
@keyframes pop   { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }

.play-row { position: relative; width: fit-content; display: flex; align-items: center; gap: 12px; }
.hint-section { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 90px; }
.hint-controls { display: flex; gap: 4px; align-items: center; }

.undo-btn, .reset-btn {
  font-size: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  opacity: 0.6;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.undo-btn:hover:not(:disabled), .reset-btn:hover:not(:disabled) { opacity:1; transform: scale(1.2); }
.undo-btn:disabled, .reset-btn:disabled { opacity:0.15; cursor:not-allowed; }

.controls { display: flex; justify-content: center; gap: 6px; }

.controls button {
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 5px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.controls button:hover { background: #7c3aed; transform: translateY(-1px); }

.status {
  font-size: 12px;
  text-align: center;
  min-height: 20px;
  font-weight: 600;
  animation: fadeIn 0.3s ease;
  padding: 0 0.5rem;
}

.bank {
  width: 100%;
  background: #11151c;
  border-top: 2px solid #222a34;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bank h4 {
  font-size: 12px;
  margin: 0;
  letter-spacing: 1.5px;
  color: #fbbf24;
  font-weight: 600;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 400px;
  padding: 0 0.5rem;
}

.buttons button {
  font-size: 11px;
  padding: 10px 8px;
  border-radius: 4px;
  border: 2px solid #fbbf24;
  background: #f59e0b;
  color: #1a1206;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.buttons button:hover:not(:disabled) {
  background: #fbbf24;
  border-color: #fde68a;
  transform: translateY(-2px);
}

.buttons button:disabled { opacity: 0.3; cursor: not-allowed; background: #1e293b; border-color: #334155; color: #94a3b8; }

.copyright {
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  padding: 6px 0 10px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  :root { --tile: 28px; }
  .logo { height: 28px; }
  .buttons button { font-size: 9px; }
}

.puzzle-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: #94a3b8;
  min-height: 14px;
}
.puzzle-label.daily { color: #34d399; }

.top-row button.daily-btn {
  background: #059669;
  position: relative;
}
.top-row button.daily-btn:hover { background: #10b981; }
.top-row button.daily-btn.is-new::after {
  content: "NEW";
  position: absolute;
  top: -8px;
  right: -10px;
  background: #ef4444;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 4px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.controls { flex-wrap: wrap; }
.top-row button.share-btn { background: #0ea5e9; }
.top-row button.share-btn:hover { background: #38bdf8; }

.header { position: relative; width: 100%; }
.help-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.help-modal[hidden] { display: none; }
.help-card {
  position: relative; background: #161a22; border: 1px solid #2a3240; border-radius: 10px;
  max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 20px 20px 16px; color: #e2e8f0; font-size: 14px; line-height: 1.5;
}
.help-card h2 { margin: 0 0 8px; font-size: 18px; color: #fbbf24; }
.help-card p { margin: 8px 0; }
.help-card ol { margin: 8px 0; padding-left: 20px; }
.help-card li { margin: 4px 0; }
.help-close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: #94a3b8; font-size: 22px; cursor: pointer;
}
.help-ok {
  display: block; margin: 12px auto 0; background: #059669; color: #fff; border: none;
  border-radius: 6px; padding: 8px 18px; font-weight: 700; cursor: pointer;
}
.help-ok:hover { background: #10b981; }

.top-row {
  display: flex; justify-content: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 12px 0; flex-shrink: 0;
}
.top-row button {
  font-size: 11px; padding: 6px 12px; border-radius: 5px; border: none;
  color: #fff; cursor: pointer; font-weight: 600; transition: all 0.2s ease;
}
.top-row button:hover { transform: translateY(-1px); }
.top-row button.help-btn { background: #334155; }
.top-row button.help-btn:hover { background: #475569; }
