:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --tile-empty: #e5e7eb;
  --board-bg: #f1f5f9;
  --text: #334155;
  --text-dim: #64748b;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}

.card {
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px 28px 24px;
  width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.date-note {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 14px;
}

.slot-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.slot-tab {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: var(--tile-empty);
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.slot-tab:hover { background: #dbeafe; }

.slot-tab.active {
  background: #3b82f6;
  color: #fff;
}

.slot-tab.solved {
  background: #dcfce7;
  color: #16a34a;
}

.slot-tab.solved.active {
  background: #16a34a;
  color: #fff;
}

.slot-tab.locked {
  cursor: not-allowed;
  opacity: 0.5;
}

.slot-tab.locked:hover { background: var(--tile-empty); }

.status {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  min-height: 2.4em;
  margin-bottom: 12px;
  padding: 0 8px;
}

.board-wrap {
  position: relative;
  width: 264px;
  height: 264px;
}

.board {
  position: relative;
  width: 264px;
  height: 264px;
  background: var(--board-bg);
  border-radius: 16px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  transform-origin: 50% 50%;
}

.tile-cell {
  border-radius: 10px;
  background: var(--tile-empty);
  position: relative;
}

.tile {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  transform-origin: 50% 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.tile.empty {
  background: transparent !important;
  box-shadow: none;
}

.tile-label {
  display: inline-block;
}

.win-overlay {
  position: absolute;
  inset: -8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
}

.win-overlay.hidden { display: none; }

.win-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.win-emoji { font-size: 1.6rem; }
.win-title { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.win-sub { color: var(--text-dim); font-size: 0.9rem; }
.win-moves { margin-top: 10px; font-size: 0.95rem; }
.win-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 8px; max-width: 220px; }
.win-hint.hidden { display: none; }

.win-comeback { font-size: 0.85rem; color: var(--text-dim); margin-top: 16px; max-width: 220px; }
.win-comeback.hidden { display: none; }

.link-btn {
  margin-top: 16px;
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.dead-end-banner {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.78rem;
  text-align: center;
  max-width: 264px;
}

.dead-end-banner.hidden { display: none; }

.link-btn.hidden { display: none; }

.controls {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 264px;
  min-height: 40px;
  transition: opacity 0.2s ease;
}

.controls.dimmed {
  opacity: 0.1;
  pointer-events: none;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: flex;
}

.icon-btn:hover { background: var(--tile-empty); }

.icon-btn svg {
  width: 30px;
  height: 30px;
  fill: var(--text);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.text-btn.hidden, .icon-btn.hidden { visibility: hidden; }

.footer-note {
  margin-top: 18px;
  font-size: 0.7rem;
  color: #94a3b8;
  text-align: center;
  min-height: 1em;
}
