:root {
  --bg: #03152b;
  --bg-deep: #021124;
  --surface: rgba(12, 40, 72, .86);
  --surface-strong: rgba(16, 51, 88, .96);
  --line: rgba(143, 177, 211, .24);
  --line-strong: rgba(255, 194, 62, .48);
  --text: #f6f8fc;
  --muted: #94a9c4;
  --gold: #ffc23e;
  --gold-deep: #d89a12;
  --radius: 8px;
  --shadow: 0 22px 60px rgba(0, 8, 24, .38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% -8%, rgba(20, 84, 137, .38), transparent 19rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(to bottom, #000, transparent 76%);
}

button,
a,
input {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.phone-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.topbar {
  min-height: calc(90px + env(safe-area-inset-top));
  margin: 0 -16px;
  padding: calc(15px + env(safe-area-inset-top)) 18px 15px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid rgba(77, 134, 188, .35);
  background: rgba(2, 17, 36, .96);
  box-shadow: 0 12px 28px rgba(0, 8, 24, .22);
}

.brand-trigger {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .32));
}

.topbar div {
  min-width: 0;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.action svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.carousel-section {
  position: relative;
  height: 350px;
  min-height: 350px;
  margin: 0 -16px;
  touch-action: pan-y;
}

.carousel-section::after {
  display: none;
}

.arc-stage {
  position: absolute;
  inset: 0;
  perspective: 900px;
}

.arc-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 158px;
  height: 208px;
  padding: 5px;
  border: 2px solid rgba(255, 194, 62, .62);
  border-radius: 18px;
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 18px 42px rgba(0, 8, 24, .42);
  transition: transform .28s ease, opacity .28s ease, border-color .28s ease;
  overflow: hidden;
  transform-style: preserve-3d;
}

.arc-card.selected {
  border-color: var(--gold);
  box-shadow: 0 22px 54px rgba(0, 8, 24, .48), 0 0 0 7px rgba(255, 194, 62, .1);
}

.arc-card img,
.avatar-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 13px;
  object-fit: cover;
  background:
    linear-gradient(145deg, rgba(255, 194, 62, .92), rgba(0, 96, 143, .78)),
    var(--surface-strong);
  color: #071b34;
  font-family: "Bebas Neue", sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
}

.arc-name {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 7px;
  padding: 32px 9px 8px;
  border-radius: 0 0 13px 13px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.05;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .76));
  text-shadow: 0 1px 8px rgba(0, 0, 0, .7);
}

.detail-stack[hidden] {
  display: none;
}

.detail-stack {
  display: grid;
  gap: 12px;
  margin-top: -12px;
  padding-bottom: 24px;
}

.profile-panel,
.responsibility-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
}

.profile-panel {
  padding: 16px;
}

.profile-role {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
}

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

.action {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, .055);
}

.action.primary {
  border-color: rgba(255, 194, 62, .72);
  color: #071b34;
  background: linear-gradient(180deg, #ffe28a, var(--gold) 58%, var(--gold-deep));
}

.action span {
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
}

.responsibility-panel {
  padding: 14px;
}

.responsibility-panel h3 {
  margin: 0 0 10px;
  font-family: "Bebas Neue", sans-serif;
  font-size: 25px;
  letter-spacing: .8px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 7px 9px;
  border: 1px solid rgba(255, 194, 62, .26);
  border-radius: 999px;
  color: #ffe3a0;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 194, 62, .08);
}

.settings-dialog {
  width: min(100% - 22px, 430px);
  max-height: min(94svh, 820px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--bg);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .58);
}

.settings-dialog::backdrop {
  background: rgba(0, 5, 14, .72);
}

.settings-sheet {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.settings-head {
  display: flex;
  align-items: start;
  gap: 12px;
}

.settings-head h2,
.settings-head p {
  margin: 0;
}

.settings-head h2 {
  font-family: "Bebas Neue", sans-serif;
  font-size: 32px;
  letter-spacing: 1px;
}

.settings-head p,
.settings-status {
  color: var(--muted);
  font-size: 12px;
}

#settingsClose {
  width: 38px;
  height: 38px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  background: rgba(255, 255, 255, .05);
}

.pin-field,
.pin-change label,
.settings-card label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pin-field[hidden] {
  display: none;
}

.pin-field input,
.pin-change input,
.settings-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
}

.settings-list {
  display: grid;
  gap: 12px;
}

.settings-card {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.settings-card legend {
  padding: 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.image-control {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
}

.image-preview {
  width: 92px;
  height: 112px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255, 194, 62, .92), rgba(0, 96, 143, .78));
}

.image-preview img,
.image-preview span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  object-fit: cover;
  color: #071b34;
  font-family: "Bebas Neue", sans-serif;
  font-size: 30px;
}

.upload-button,
.clear-image {
  min-height: 42px;
  width: 100%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  background: rgba(255, 255, 255, .06);
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.clear-image {
  margin-top: 8px;
  color: var(--muted);
}

.pin-change {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.pin-change[hidden] {
  display: none;
}

.pin-change h3 {
  margin: 0;
  color: var(--gold);
  font-size: 15px;
}

.pin-change button {
  min-height: 44px;
  border: 1px solid rgba(255, 194, 62, .62);
  border-radius: var(--radius);
  color: #071b34;
  font-weight: 900;
  background: var(--gold);
}

.remove-person,
.settings-actions button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 800;
  background: rgba(255, 255, 255, .06);
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
}

.settings-actions button[type="submit"] {
  border-color: rgba(255, 194, 62, .76);
  color: #071b34;
  background: var(--gold);
}

.settings-status {
  min-height: 18px;
  margin: 0;
}

@media (max-width: 360px) {
  .topbar h1 {
    font-size: 23px;
  }

  .actions,
  .settings-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arc-card {
    transition: none;
  }
}
