/* Shared components. */

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 6px;
  min-height: 60px;
}

.topbar-title {
  min-width: 0;
  text-align: center;
}

.topbar-title h1 {
  font-size: 1.15em;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  font-size: 0.8em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  min-width: 44px;
}

.topbar-spacer {
  width: 44px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: transform 0.12s ease, background 0.2s;
}

.icon-btn:active {
  transform: scale(0.94);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-weight: 700;
  white-space: nowrap;
}

.coin-dot {
  color: var(--gold);
  display: grid;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 20px;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, filter 0.2s, background 0.2s;
  text-align: center;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn.primary {
  background: linear-gradient(180deg, var(--blue-2), var(--blue));
  box-shadow: 0 8px 22px rgba(30, 107, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--line-strong);
}

.btn.soft {
  background: var(--panel);
  border: 1px solid var(--line);
}

.btn.danger {
  background: rgba(255, 90, 110, 0.14);
  border: 1.5px solid rgba(255, 90, 110, 0.55);
  color: #ffd2d8;
}

.btn.small {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.9em;
  gap: 4px;
}

.btn.wide {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  filter: saturate(0.5);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  margin-top: auto;
  background: linear-gradient(180deg, transparent, var(--bg0) 45%);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stars {
  display: inline-flex;
  gap: 2px;
}

.star {
  color: rgba(255, 255, 255, 0.22);
  display: grid;
}

.star.on {
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.55));
}

.star.on svg {
  fill: currentColor;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--cyan), var(--blue-2));
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 0.8em;
  color: var(--muted);
  white-space: nowrap;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan);
  font-weight: 800;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: left;
}

.nav-row-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--cyan-soft);
  color: var(--cyan);
  flex: none;
}

.nav-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.nav-row-text small {
  color: var(--muted);
}

.nav-row-chev {
  color: var(--muted);
}

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toggle-text small {
  color: var(--muted);
}

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-knob {
  position: absolute;
  inset: 0;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.2s;
}

.switch-knob::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.switch input:checked + .switch-knob {
  background: var(--blue);
}

.switch input:checked + .switch-knob::after {
  transform: translateX(22px);
}

.switch input:focus-visible + .switch-knob {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.slider-row {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
}

.slider-value {
  color: var(--cyan);
  font-weight: 700;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--blue-2);
  height: 28px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
  min-width: 0;
}

.stat-tile strong {
  font-size: 1.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.stat-tile small {
  color: var(--muted);
  font-size: 0.74em;
  line-height: 1.2;
}

.stat-icon {
  color: var(--cyan);
  margin-bottom: 2px;
}

.avatar {
  display: block;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 6px 16px rgba(0, 0, 0, 0.35);
}

.avatar.md {
  width: 52px;
  height: 52px;
}

.avatar.xl {
  width: 108px;
  height: 108px;
}

.card-art {
  display: block;
  border-radius: 12px;
  background: #fff;
  aspect-ratio: 3 / 4;
  padding: 10%;
  box-shadow: 0 6px 16px rgba(0, 10, 50, 0.35);
}

.card-art.unknown {
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.85);
}

.card-art.unknown > svg {
  width: 30%;
  height: auto;
  aspect-ratio: 1;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

.note,
.tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9em;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--cyan-soft);
  border: 1px solid rgba(79, 227, 255, 0.25);
}

.note svg,
.tip svg {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--cyan);
}

.tip {
  background: var(--panel);
  border-color: var(--line);
}

/* Overlays */
#overlay-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 24, 0.72);
  opacity: 0;
  transition: opacity 0.2s;
}

.overlay-layer.open .backdrop {
  opacity: 1;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 18px calc(22px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #13307e, #081a4d);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.overlay-layer.open .sheet {
  transform: none;
}

.overlay-layer.closing .sheet {
  transform: translateY(100%);
}

.overlay-layer.closing .backdrop {
  opacity: 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-head h2 {
  font-size: 1.2em;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.confirm p {
  margin-bottom: 14px;
}

#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(10, 26, 78, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 0.92em;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.good {
  border-color: rgba(61, 220, 151, 0.6);
}

.toast.good svg {
  color: var(--good);
}

.toast.warn {
  border-color: rgba(255, 209, 102, 0.6);
}

.toast.warn svg {
  color: var(--gold);
}

.mask-preview {
  display: grid;
  gap: 3px;
  width: 64px;
}

.mask-preview.big {
  width: 150px;
  gap: 5px;
  margin: 6px auto;
}

.mask-preview .cell {
  aspect-ratio: 3 / 4;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.mask-preview .cell.on {
  background: linear-gradient(180deg, var(--blue-2), var(--blue-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.limit-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.limit {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.limit.calm {
  color: var(--good);
}

.limit.bonus {
  background: rgba(255, 209, 102, 0.18);
  color: var(--gold);
}

.record-list {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
}

.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
}

.record-row + .record-row {
  border-top: 1px solid var(--line);
}

.record-row span {
  color: var(--muted);
}

.record-row strong {
  text-align: right;
}
