:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --page-bg:
    radial-gradient(circle at top center, rgba(191, 219, 254, 0.34), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-border: rgba(226, 232, 240, 0.95);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --blue-cell: #dbeafe;
  --blue-border: #bfdbfe;
  --path-fill: #cbd5e1;
  --path-strong: #64748b;
  --solid-fill: #334155;
  --locked-fill: #f8fafc;
  --accent: #2563eb;
  --shadow:
    0 20px 44px rgba(148, 163, 184, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text-main);
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  max-width: 30rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 1rem)
    1rem
    calc(env(safe-area-inset-bottom) + 1rem);
}

.topbar {
  display: grid;
  grid-template-columns: 5rem 1fr 5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0.95rem;
  border: 1px solid var(--card-border);
  border-radius: 1.45rem;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar-button {
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 0.85rem;
  background: rgba(239, 246, 255, 0.88);
  color: var(--accent);
  padding: 0.62rem 0.9rem;
  cursor: pointer;
}

.topbar-title {
  margin: 0;
  text-align: center;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hero-panels {
  margin-top: 1rem;
  padding: 1.3rem;
  border: 1px solid var(--card-border);
  border-radius: 1.9rem;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  border: 1px solid var(--card-border);
  border-radius: 1.55rem;
  background: rgba(255, 255, 255, 0.96);
  padding: 1.5rem 1.2rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.panel + .panel {
  margin-top: 0.9rem;
}

.panel-caption {
  margin: 0;
  color: var(--text-soft);
  text-align: center;
  font-size: 0.74rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.panel-value {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.timer-value {
  font-size: 2.15rem;
  letter-spacing: 0.2em;
}

.feature-chips {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.feature-chip {
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.76rem;
  font-weight: 500;
}

.feature-chip--neutral {
  background: #f1f5f9;
  color: var(--text-muted);
}

.status-message {
  margin: 0.95rem 0 0;
  padding: 0.82rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--card-border);
  background: #f8fafc;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

.board-section {
  margin-top: auto;
  padding-top: 1rem;
}

.board {
  width: min(100%, 28rem);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 0.85rem;
  display: grid;
  gap: 0.48rem;
  border: 1px solid var(--card-border);
  border-radius: 1.9rem;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--blue-border);
  border-radius: 1.2rem;
  background: var(--blue-cell);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.45rem;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.cell.is-tail {
  transform: translateY(-0.08rem);
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.28) inset;
}

.cell.is-visited {
  background: var(--path-fill);
  border-color: #94a3b8;
}

.cell.is-solid {
  background: var(--solid-fill);
  border-color: #1e293b;
  color: #ffffff;
  cursor: not-allowed;
}

.cell.is-locked-end {
  background: var(--locked-fill);
  border-style: dashed;
  color: var(--text-muted);
}

.cell.is-direction {
  background: rgba(255, 255, 255, 0.98);
  border-color: #dbe4ef;
}

.cell__badge {
  position: relative;
  z-index: 2;
  border-radius: 999px;
  padding: 0.26rem 0.58rem;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text-muted);
}

.cell__badge--accent {
  background: rgba(59, 130, 246, 0.14);
  color: var(--accent);
}

.cell__label {
  position: relative;
  z-index: 2;
  margin-top: auto;
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.cell__icon {
  position: relative;
  z-index: 2;
  margin-top: auto;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.cell__icon--arrow {
  color: #475569;
}

.path-node {
  position: absolute;
  inset: 24%;
  border-radius: 999px;
  background: var(--path-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.path-link {
  position: absolute;
  border-radius: 999px;
  background: var(--path-strong);
}

.path-link--up {
  left: 50%;
  top: -26%;
  width: 0.72rem;
  height: 60%;
  transform: translateX(-50%);
}

.path-link--right {
  right: -26%;
  top: 50%;
  width: 60%;
  height: 0.72rem;
  transform: translateY(-50%);
}

.path-link--down {
  left: 50%;
  bottom: -26%;
  width: 0.72rem;
  height: 60%;
  transform: translateX(-50%);
}

.path-link--left {
  left: -26%;
  top: 50%;
  width: 60%;
  height: 0.72rem;
  transform: translateY(-50%);
}

.result-panel {
  margin-top: auto;
}

.result-title {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.12em;
}

.result-time {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.result-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.7rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 1rem;
  background: #f8fafc;
  padding: 0.92rem 1rem;
  color: var(--text-muted);
}

.result-row strong {
  color: var(--text-main);
}

.result-actions {
  margin-top: 1.2rem;
  display: flex;
  gap: 0.75rem;
}

.primary-button,
.secondary-button {
  flex: 1;
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
}

.primary-button {
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #ffffff;
}

.secondary-button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-muted);
}

@media (max-width: 420px) {
  .page-shell {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .panel-value,
  .result-time {
    font-size: 2.2rem;
  }

  .timer-value {
    font-size: 1.95rem;
  }

  .cell {
    border-radius: 1rem;
  }
}
