:root {
  --blue: #111bd6;
  --blue-soft: #e7ebff;
  --green: #198754;
  --red: #dc3545;
  --danger: #8b0000;
  --ink: #111111;
  --muted: #5f6673;
  --line: #d8dbe3;
  --panel: #ffffff;
  --soft: #f4f5f8;
  --blog: #f9f7f3;
  --blog-line: #ede8dc;
  --shadow: 0 18px 50px rgba(18, 24, 40, 0.14);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: "Comic Neue", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

img {
  max-width: 100%;
  display: block;
}

.app-root {
  width: 100%;
  min-height: 100vh;
  background: #ffffff;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.screen-inner {
  width: min(100%, 720px);
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen-inner.wide {
  width: min(100%, 920px);
}

.boot-screen,
.center-state,
.empty-state {
  min-height: 62vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.empty-state {
  align-content: center;
  gap: 18px;
}

.empty-state img {
  width: min(200px, 58vw);
  margin: 0 auto;
}

.empty-state p {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(216, 219, 227, 0.72);
  backdrop-filter: blur(12px);
}

.app-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 900;
  text-align: left;
}

.app-actions,
.app-leading {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--blue);
  background: transparent;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--blue-soft);
  outline: none;
}

.icon-button.danger {
  color: var(--danger);
}

.icon-button.dark {
  color: #222222;
}

.icon {
  width: 22px;
  height: 22px;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.content-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.padded {
  padding: 16px;
}

.auth-screen {
  width: min(100%, 540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 26px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #ffffff;
}

.auth-screen h1 {
  margin: 10px 0 26px;
  font-size: 34px;
  line-height: 1.08;
  text-align: center;
  font-weight: 900;
}

.auth-screen h2 {
  margin: 0 0 20px;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 900;
}

.auth-art {
  width: min(420px, 100%);
  margin: 0 auto 28px;
  object-fit: contain;
}

.auth-art.small {
  width: 190px;
}

.auth-art.medium {
  width: 230px;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #1c2230;
  font-size: 14px;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 52px;
  padding: 13px 14px;
  border: 1px solid #b8bdc7;
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.field textarea {
  min-height: 98px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(17, 27, 214, 0.14);
}

.helper {
  margin: -2px 0 2px;
  color: rgba(0, 0, 0, 0.58);
  font-size: 12px;
  line-height: 1.35;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
}

.primary-button,
.secondary-button,
.danger-button,
.success-button,
.plain-button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  text-align: center;
}

.primary-button {
  background: var(--blue);
  color: #ffffff;
}

.secondary-button {
  background: #ffffff;
  color: var(--blue);
  border-color: var(--blue);
}

.danger-button {
  background: var(--danger);
  color: #ffffff;
}

.success-button {
  background: var(--green);
  color: #ffffff;
}

.plain-button {
  min-height: 40px;
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}

.full-width {
  width: 100%;
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.banner {
  width: 100%;
  padding: 10px 16px;
  background: #c51622;
  color: #ffffff;
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
}

.rebus-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rebus-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
}

.rebus-heading {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.1;
  text-align: center;
  font-weight: 900;
}

.rebus-image-frame {
  width: min(100%, 620px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 24px;
  overflow: hidden;
  background: var(--soft);
}

.rebus-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hint-text {
  margin: 14px 0 8px;
  text-align: center;
  font-size: 20px;
  line-height: 1.25;
}

.bottom-action {
  padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: #ffffff;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.tab-button {
  min-height: 48px;
  border: 0;
  background: #ffffff;
  color: rgba(0, 0, 0, 0.58);
  border-bottom: 3px solid transparent;
  font-weight: 900;
}

.tab-button.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.list {
  display: grid;
  gap: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(216, 219, 227, 0.8);
}

.row:last-child {
  border-bottom: 0;
}

.rank-pos {
  width: 38px;
  flex: 0 0 38px;
  color: rgba(0, 0, 0, 0.56);
  font-size: 17px;
  font-weight: 900;
}

.rank-pos.gold {
  color: #ffab00;
}

.rank-pos.silver {
  color: #9e9e9e;
}

.rank-pos.bronze {
  color: #bf8c5a;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--blue-soft);
  color: var(--blue);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-main {
  min-width: 0;
  flex: 1;
}

.row-title {
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  margin-top: 2px;
  color: rgba(0, 0, 0, 0.48);
  font-size: 12px;
  line-height: 1.25;
}

.row-value {
  flex: 0 0 auto;
  color: var(--blue);
  text-align: right;
  font-weight: 900;
}

.row-value small {
  display: block;
  margin-top: 2px;
  color: rgba(0, 0, 0, 0.46);
  font-size: 11px;
}

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

.item-card,
.blog-card,
.profile-card,
.ranking-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.item-card {
  width: 100%;
  padding: 12px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-align: left;
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  width: 100%;
  height: 100%;
  min-height: 64px;
  display: grid;
  place-items: center;
  color: rgba(0, 0, 0, 0.42);
  background: #e5e7eb;
}

.detail-hero {
  min-height: 210px;
  display: grid;
  align-items: end;
  position: relative;
  overflow: hidden;
  background: #e5e7eb;
}

.detail-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 35% 0 0;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.74));
}

.detail-hero h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 16px;
  color: #ffffff;
  font-size: 22px;
  line-height: 1.15;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.ranking-card {
  padding: 14px;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.ranking-card .rank-big {
  color: var(--blue);
  font-size: 28px;
  font-weight: 900;
}

.profile-wrap {
  position: relative;
  min-height: calc(100vh - 58px);
  padding: 64px 16px 120px;
  overflow: hidden;
}

.profile-card {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 28px;
  text-align: center;
  box-shadow: 0 8px 22px rgba(18, 24, 40, 0.08);
}

.profile-avatar {
  position: relative;
  width: 124px;
  height: 124px;
  margin: 0 auto 24px;
}

.profile-avatar .avatar {
  width: 124px;
  height: 124px;
}

.avatar-edit {
  position: absolute;
  right: 2px;
  bottom: 2px;
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.profile-label {
  margin: 0;
  color: rgba(0, 0, 0, 0.56);
  font-size: 13px;
}

.profile-value {
  margin: 4px 0 18px;
  overflow-wrap: anywhere;
  font-size: 19px;
  line-height: 1.25;
}

.profile-mouse {
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: min(520px, 120vw);
  transform: translateX(-50%);
  opacity: 0.95;
}

.version {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  color: #8c8f98;
  text-align: center;
  font-size: 11px;
}

.blog-card {
  border-color: var(--blog-line);
  background: var(--blog);
}

.blog-card button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.blog-image {
  aspect-ratio: 16 / 9;
  background: #f3f4f6;
  overflow: hidden;
}

.blog-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blog-copy {
  padding: 14px;
}

.blog-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.blog-summary {
  margin: 8px 0 0;
  color: rgba(0, 0, 0, 0.58);
  font-size: 14px;
  line-height: 1.4;
}

.blog-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  color: rgba(0, 0, 0, 0.42);
  font-size: 12px;
}

.blog-meta .read-more {
  margin-left: auto;
  color: var(--blue);
  font-size: 13px;
}

.blog-detail {
  padding: 8px 16px 32px;
}

.blog-detail h1 {
  margin: 16px 0 8px;
  font-size: 24px;
  line-height: 1.3;
}

.blog-body {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: rgba(0, 0, 0, 0.84);
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 200;
  display: grid;
  justify-items: center;
  pointer-events: none;
  padding: 0 14px;
}

.toast {
  max-width: 560px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #20242e;
  color: #ffffff;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.toast.success {
  background: #188044;
}

.toast.error {
  background: #c12832;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 20, 31, 0.42);
}

.dialog-card,
.sheet-card {
  width: min(100%, 520px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog-card {
  padding: 20px;
}

.dialog-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.dialog-title-row h2 {
  margin: 0;
  flex: 1;
  font-size: 20px;
  line-height: 1.2;
}

.dialog-card p {
  margin: 0 0 16px;
  color: rgba(0, 0, 0, 0.72);
  line-height: 1.38;
}

.dialog-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dialog-list div {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-list div:last-child {
  border-bottom: 0;
}

.sheet-overlay {
  align-items: end;
  padding: 0;
}

.sheet-card {
  width: 100%;
  max-width: 720px;
  border-radius: 8px 8px 0 0;
  padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
}

.sheet-card h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(17, 27, 214, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.spinner.small {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 760px) {
  body {
    background: #f3f5fb;
  }

  .app-root {
    background: #f3f5fb;
  }

  .screen-inner,
  .auth-screen {
    min-height: 100vh;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(216, 219, 227, 0.6);
  }

  .screen-inner.wide {
    box-shadow: 0 0 0 1px rgba(216, 219, 227, 0.6);
  }
}

@media (max-width: 390px) {
  .app-title {
    font-size: 18px;
  }

  .auth-screen h1,
  .auth-screen h2 {
    font-size: 30px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }
}
