﻿:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161d25;
  --panel-alt: #202934;
  --panel-soft: #293340;
  --line: #364351;
  --line-soft: #526173;
  --text: #f4f7fb;
  --muted: #a4afbb;
  --accent: #7aa8ff;
  --accent-strong: #4f86ec;
  --danger: #e05656;
  --danger-deep: #ae3030;
  --remove-soft: #d9dee7;
  --remove-text: #2c3440;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI Variable", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(88, 128, 196, 0.18) 0, transparent 34%),
    radial-gradient(circle at top right, rgba(208, 164, 76, 0.1) 0, transparent 28%),
    linear-gradient(180deg, #0a0f14 0%, #0d1117 42%, #121923 100%);
  color: var(--text);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  color: inherit;
  border: 0;
  background: none;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  overflow-x: clip;
}

.ranking-view,
.ranking-view * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.ranking-view {
  -webkit-tap-highlight-color: transparent;
}

.ranking-view img {
  -webkit-user-drag: none;
  user-drag: none;
}

.app-topbar {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #0d1014;
}

.back-button {
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid var(--accent);
  background: rgba(122, 168, 255, 0.08);
  color: var(--accent);
  font-size: 13px;
}

.topbar-brand {
  min-width: 0;
  max-width: min(100%, 520px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 10px;
}

.topbar-brand-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 800;
}

.topbar-brand-logo {
  flex: 0 0 auto;
  width: min(92px, 23vw);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.page-shell {
  width: min(calc(100% - 32px), 1240px);
  margin: 0 auto;
  padding: 12px 0 24px;
  min-width: 0;
}

.panel {
  background: linear-gradient(180deg, #18212b 0%, #121821 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.page-panel {
  padding: 10px;
}

.home-panel {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: min(100%, 520px);
  min-height: min(calc(100vh - 40px), 840px);
  margin: 0 auto;
  padding: clamp(52px, 9vh, 104px) 16px 22px;
  background: linear-gradient(180deg, #18212b 0%, #121821 100%);
}

.home-panel-background {
  --home-theme-image-inset: 1px;
  --home-theme-image-scale: 1;
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  isolation: isolate;
  box-shadow: inset 0 0 24px rgba(8, 12, 18, 0.12);
}

.home-panel-background::before,
.home-panel-background::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.home-panel-background::before {
  z-index: 0;
  inset: var(--home-theme-image-inset);
  border-radius: inherit;
  background-image: var(--home-theme-bg-image, none);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: var(--home-theme-bg-position, center center);
  opacity: 0.96;
  filter: saturate(1.03) brightness(0.97);
  transform: scale(var(--home-theme-image-scale));
  transform-origin: center;
  -webkit-mask-image: radial-gradient(
    ellipse 116% 112% at center,
    rgba(0, 0, 0, 1) 60%,
    rgba(0, 0, 0, 0.96) 76%,
    rgba(0, 0, 0, 0.72) 88%,
    rgba(0, 0, 0, 0.24) 96%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse 116% 112% at center,
    rgba(0, 0, 0, 1) 60%,
    rgba(0, 0, 0, 0.96) 76%,
    rgba(0, 0, 0, 0.72) 88%,
    rgba(0, 0, 0, 0.24) 96%,
    transparent 100%
  );
}

.home-panel-background::after {
  z-index: 1;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.05) 0, rgba(255, 255, 255, 0) 72%),
    radial-gradient(ellipse 118% 114% at center, rgba(10, 15, 21, 0) 58%, rgba(10, 15, 21, 0.08) 82%, rgba(10, 15, 21, 0.2) 100%);
  opacity: 0.24;
  transition: opacity 560ms ease;
}

.home-panel-background-blackout {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: linear-gradient(180deg, #18212b 0%, #121821 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

.home-panel-background.is-theme-fading-out .home-panel-background-blackout {
  opacity: 1;
}

.home-panel-background.is-theme-fading-in .home-panel-background-blackout {
  opacity: 0;
  transition-duration: 560ms;
}

.home-panel::before,
.home-panel::after {
  content: "";
  position: absolute;
  z-index: 1;
  border-radius: 999px;
  pointer-events: none;
}

.home-panel::before {
  width: 320px;
  height: 320px;
  top: -120px;
  right: -72px;
  background: radial-gradient(circle, rgba(255, 199, 106, 0.12) 0, rgba(255, 199, 106, 0) 70%);
}

.home-panel::after {
  width: 360px;
  height: 360px;
  bottom: -180px;
  left: -90px;
  background: radial-gradient(circle, rgba(122, 168, 255, 0.14) 0, rgba(122, 168, 255, 0) 68%);
}

.home-stack {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: clamp(8px, 1.4vh, 18px);
}

.home-card,
.home-action-button {
  width: calc(100% - 24px);
  margin-inline: auto;
  border: 1px solid rgba(123, 141, 164, 0.7);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(9px) saturate(1.08);
  backdrop-filter: blur(9px) saturate(1.08);
}

.home-card {
  border-radius: 20px;
  padding: 18px 18px 20px;
  background:
    linear-gradient(180deg, rgba(36, 48, 61, 0.58) 0%, rgba(24, 32, 42, 0.68) 100%);
}

.home-action-button {
  border-radius: 14px;
}

.home-hero-card {
  min-height: 188px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 14px;
  background:
    radial-gradient(circle at top, rgba(255, 199, 106, 0.14) 0, transparent 42%),
    linear-gradient(180deg, rgba(36, 48, 61, 0.66) 0%, rgba(22, 29, 37, 0.78) 100%);
}

.home-hero-logo {
  width: min(137px, 39vw);
  max-width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.24));
}

.home-hero-title {
  margin: 0;
  font-size: clamp(28px, 6.8vw, 38px);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.home-card-title {
  margin-bottom: 10px;
  color: rgba(228, 236, 248, 0.78);
  font-size: 14px;
  font-weight: 700;
}

.home-subject-card {
  position: relative;
  z-index: 6;
}

.home-subject-card .subject-toggle {
  min-height: 60px;
  padding-inline: 12px 42px;
}

.home-action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  padding: 0 24px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  touch-action: manipulation;
}

.home-action-button {
  background:
    linear-gradient(180deg, rgba(255, 199, 106, 0.12) 0%, rgba(191, 130, 47, 0.08) 100%),
    linear-gradient(180deg, rgba(37, 47, 58, 0.34) 0%, rgba(24, 31, 39, 0.46) 100%);
  border-color: rgba(255, 199, 106, 0.52);
  color: #fff2cf;
}

.home-subject-card .subject-toggle {
  background: linear-gradient(180deg, rgba(33, 45, 57, 0.38) 0%, rgba(24, 33, 43, 0.5) 100%);
  -webkit-backdrop-filter: blur(7px) saturate(1.04);
  backdrop-filter: blur(7px) saturate(1.04);
}

.ranking-view {
  position: relative;
  isolation: isolate;
  padding: 10px;
  overflow-x: clip;
  overscroll-behavior-x: none;
  --ranking-theme-bg-image: none;
  --ranking-theme-bg-position: center top;
}

.ranking-view > :not(.ranking-view-background) {
  position: relative;
  z-index: 1;
}

.ranking-view-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  isolation: isolate;
}

.ranking-view-background::before,
.ranking-view-background::after {
  content: "";
  position: absolute;
  inset: 0;
}

.ranking-view-background::before {
  inset: 1px;
  border-radius: inherit;
  background-image: var(--ranking-theme-bg-image, none);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: var(--ranking-theme-bg-position, center top);
  opacity: 0.42;
  filter: saturate(1.04) brightness(0.82);
  transform: scale(1.03);
  transform-origin: center;
}

.ranking-view-background::after {
  background:
    linear-gradient(180deg, rgba(9, 13, 18, 0.26) 0%, rgba(9, 13, 18, 0.58) 26%, rgba(9, 13, 18, 0.84) 100%),
    radial-gradient(circle at top center, rgba(255, 199, 106, 0.14) 0, rgba(255, 199, 106, 0) 34%),
    radial-gradient(circle at left bottom, rgba(122, 168, 255, 0.16) 0, rgba(122, 168, 255, 0) 32%);
}

.ranking-page-topbar {
  display: none;
}

.ranking-back-button {
  min-width: 136px;
  font-weight: 700;
}

.subject-row {
  margin-bottom: 12px;
}

.subject-picker {
  position: relative;
  z-index: 10;
}

.subject-toggle {
  position: relative;
  width: 100%;
  min-height: 58px;
  padding: 10px 42px 10px 12px;
  border-radius: 9px;
  border: 1px solid #5d6c7f;
  background: linear-gradient(180deg, #212d39 0%, #18212b 100%);
  display: flex;
  align-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  touch-action: manipulation;
}

.subject-toggle-heading {
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
}

.subject-toggle-label {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}

.subject-toggle-icon {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: #dce7f8;
}

.subject-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #151c24;
  box-shadow: var(--shadow);
  z-index: 40;
}

.subject-option {
  width: 100%;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #232d38 0%, #1c242d 100%);
  text-align: left;
  display: grid;
  align-items: center;
  touch-action: manipulation;
}

.subject-option strong {
  font-size: 15px;
  line-height: 1.2;
}

.subject-option.is-active,
.subject-option:hover {
  border-color: var(--line-soft);
  background: var(--panel-soft);
}

.subject-option.is-disabled,
.subject-option:disabled {
  border-color: rgba(82, 97, 115, 0.45);
  background: linear-gradient(180deg, rgba(37, 46, 57, 0.78) 0%, rgba(24, 31, 39, 0.9) 100%);
  color: var(--muted);
  cursor: default;
}

.content-frame {
  display: grid;
  gap: 10px;
  min-width: 0;
  overflow-x: clip;
}

.section-panel {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: visible;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, rgba(255, 255, 255, 0.005) 100%);
  min-width: 0;
}

.waiting-panel {
  border-color: #425369;
  background: linear-gradient(180deg, rgba(74, 110, 160, 0.18) 0%, rgba(21, 28, 36, 0.98) 34%, rgba(17, 22, 29, 0.98) 100%);
}

.ranking-mode-panel {
  border-color: #4a6178;
  background:
    radial-gradient(circle at right top, rgba(255, 214, 126, 0.12) 0, transparent 34%),
    linear-gradient(180deg, rgba(57, 73, 92, 0.96) 0%, rgba(24, 31, 40, 0.98) 100%);
}

.ranking-mode-bar {
  min-height: 78px;
  padding: 10px 10px 10px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.ranking-mode-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.ranking-mode-title {
  color: var(--text);
  font-size: clamp(14px, 2.9vw, 18px);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-mode-logo {
  flex: 0 0 auto;
  margin-left: auto;
  width: min(108px, 19vw);
  max-width: 38%;
  height: auto;
  object-fit: contain;
}

.waiting-panel.is-collapsed .section-bar {
  border-bottom-color: transparent;
}

.ranking-panel {
  position: relative;
  overflow: hidden;
  border-color: #625035;
  background: linear-gradient(180deg, rgba(179, 145, 72, 0.16) 0%, rgba(28, 25, 20, 0.98) 34%, rgba(20, 18, 16, 0.98) 100%);
}

.tier-controls-panel {
  border-color: #3f5b4c;
  background: linear-gradient(180deg, rgba(76, 132, 99, 0.16) 0%, rgba(18, 26, 22, 0.98) 34%, rgba(15, 22, 18, 0.98) 100%);
}

.section-bar {
  min-height: 46px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.025);
}

.section-bar-split {
  justify-content: space-between;
  gap: 12px;
}

.section-bar-center {
  justify-content: center;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

.action-button,
.ghost-button,
.solid-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 7px;
}

.action-button,
.ghost-button {
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, rgba(122, 168, 255, 0.2) 0%, rgba(122, 168, 255, 0.09) 100%);
  color: #d9e7ff;
}

.solid-button {
  background: var(--accent);
  color: #08131f;
  font-weight: 700;
}

.waiting-strip-shell {
  position: relative;
  overflow: visible;
  padding: 10px 8px 6px;
  background: rgba(7, 11, 16, 0.14);
}

.waiting-strip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: none;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.waiting-strip::-webkit-scrollbar {
  display: none;
}

.waiting-card,
.rank-item {
  position: relative;
  flex: 0 0 auto;
  transition: opacity 160ms ease, transform 160ms ease;
}

.item-card-shell {
  position: relative;
  width: 100%;
}

.waiting-card {
  width: 82px;
}

.waiting-card.is-menu-open,
.rank-item.is-menu-open {
  z-index: 8;
}

.waiting-thumb,
.rank-thumb {
  position: relative;
  width: 82px;
  height: 82px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: #f3f6fb;
  padding: 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
}

.rank-thumb {
  width: 74px;
  height: 74px;
  border-radius: 8px;
}

.waiting-thumb img,
.rank-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.item-thumb-label {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 28px;
  padding: 18px 4px 4px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.58) 44%, rgba(0, 0, 0, 0) 100%);
  color: #f7fbff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.rank-thumb .item-thumb-label {
  min-height: 24px;
  padding: 16px 4px 3px;
  font-size: 10px;
}

.waiting-card.is-menu-open .waiting-thumb,
.rank-item.is-menu-open .rank-thumb {
  border-color: rgba(132, 181, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(132, 181, 255, 0.28);
}

.is-drag-origin {
  opacity: 0.24;
  transform: scale(0.96);
}

.item-drag-preview {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  opacity: 0.96;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.34);
}

body.is-mini-program {
  padding-top: 88px;
}

body.is-item-dragging {
  cursor: grabbing;
  user-select: none;
}

body.is-item-dragging .waiting-thumb,
body.is-item-dragging .rank-thumb {
  cursor: grabbing;
}

.waiting-toolbar {
  padding: 2px 8px 10px;
}

.waiting-slider {
  width: 100%;
  touch-action: none;
}

.waiting-slider.is-disabled {
  opacity: 0.45;
}

.waiting-slider-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(122, 168, 255, 0.12);
  border: 1px solid rgba(122, 168, 255, 0.24);
  touch-action: none;
}

.waiting-slider-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 72px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #8ab4ff 0%, #5c8ff1 100%);
  box-shadow: 0 8px 18px rgba(79, 134, 236, 0.35);
  transform: translate(0, -50%);
  touch-action: none;
}

.waiting-slider-thumb::before {
  content: none;
}

.waiting-slider.is-disabled .waiting-slider-thumb {
  pointer-events: none;
  box-shadow: none;
}

.tier-board {
  display: grid;
}

.tier-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

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

.tier-badge {
  min-height: 84px;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.tier-badge.is-compact {
  font-size: 15px;
  line-height: 1.1;
  white-space: nowrap;
  letter-spacing: -0.04em;
}

.tier-dropzone {
  --rank-items-per-row: 1;
  --rank-item-gap: 3px;
  min-height: 84px;
  padding: 5px;
  display: flex;
  flex-wrap: nowrap;
  align-content: flex-start;
  gap: var(--rank-item-gap);
}

.tier-dropzone.is-wrap-enabled {
  flex-wrap: wrap;
}

.rank-item {
  width: clamp(34px, calc((100% - (var(--rank-items-per-row) - 1) * var(--rank-item-gap)) / var(--rank-items-per-row)), 74px);
}

.rank-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.item-tier-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 16;
  display: grid;
  gap: 6px;
  width: 100%;
  max-height: 220px;
  padding: 8px 6px;
  overflow-y: auto;
  border: 1px solid rgba(93, 112, 136, 0.72);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(19, 27, 36, 0.98) 0%, rgba(10, 16, 23, 0.98) 100%);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.36);
}

.floating-item-menu-host {
  position: fixed;
  inset: 0;
  z-index: 48;
  pointer-events: none;
}

.floating-item-menu-host:empty {
  display: none;
}

.item-tier-menu.is-floating {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  max-height: none;
  transform: none;
  pointer-events: auto;
}

.item-tier-option {
  width: 100%;
  min-height: 32px;
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  touch-action: manipulation;
}

.item-tier-option:hover {
  filter: brightness(1.04);
}

.item-tier-option:active {
  transform: scale(0.98);
}

.waiting-panel.is-drop-target {
  box-shadow: inset 0 0 0 1px rgba(132, 181, 255, 0.5);
}

.waiting-strip-shell.is-drop-target {
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(132, 181, 255, 0.5);
  background: rgba(84, 130, 190, 0.16);
}

.tier-row.is-drop-target .tier-dropzone {
  background: rgba(255, 230, 167, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 214, 126, 0.35);
}

.tier-dropzone.is-empty::after {
  content: "";
}

.tier-controls-panel {
  position: relative;
  overflow: visible;
}

.tier-settings-trigger {
  width: 100%;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 0;
}

.tier-template-current {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d6f5de;
  font-size: 14px;
  font-weight: 700;
}

.tier-template-name {
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tier-template-icon {
  font-size: 12px;
  transition: transform 160ms ease;
}

.tier-settings-trigger[aria-expanded="true"] .tier-template-icon {
  transform: rotate(180deg);
}

.tier-template-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 8px;
  right: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(82, 97, 115, 0.55);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(21, 32, 26, 0.98) 0%, rgba(14, 22, 17, 0.98) 100%);
  box-shadow: var(--shadow);
  z-index: 30;
}

.tier-template-option {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(39, 64, 52, 0.9) 0%, rgba(27, 41, 34, 0.92) 100%);
  display: grid;
  gap: 4px;
  text-align: left;
  touch-action: manipulation;
}

.tier-template-option strong {
  font-size: 14px;
}

.tier-template-option.is-active,
.tier-template-option:hover {
  border-color: rgba(150, 228, 186, 0.52);
  background: linear-gradient(180deg, rgba(52, 88, 70, 0.96) 0%, rgba(34, 56, 45, 0.98) 100%);
}

.tier-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  padding: 10px 8px 0;
  background: rgba(255, 255, 255, 0.02);
}

.tier-chip,
.tier-add {
  min-height: 40px;
  border-radius: 8px;
}

.tier-chip {
  border: 1px solid transparent;
  background: rgba(122, 168, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 6px 0 10px;
}

.tier-chip-label {
  width: 100%;
  color: inherit;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.tier-delete {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(217, 222, 231, 0.95);
  color: #333c47;
  font-size: 14px;
  line-height: 1;
}

.tier-add {
  width: 100%;
  border: 1px solid rgba(150, 228, 186, 0.52);
  background: linear-gradient(180deg, rgba(90, 174, 124, 0.22) 0%, rgba(90, 174, 124, 0.1) 100%);
  color: #d9ffea;
  font-size: 13px;
  font-weight: 700;
}

.page-actions {
  padding-top: 14px;
  display: grid;
  gap: 10px;
}

.share-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hide-ui-button,
.share-button,
.share-reward-button,
.export-button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.hide-ui-button {
  border: 1px solid rgba(132, 181, 255, 0.55);
  background: linear-gradient(180deg, rgba(132, 181, 255, 0.22) 0%, rgba(73, 110, 185, 0.16) 100%);
  color: #e2edff;
}

.share-button {
  border: 1px solid rgba(255, 199, 106, 0.55);
  background: linear-gradient(180deg, rgba(255, 199, 106, 0.2) 0%, rgba(191, 130, 47, 0.16) 100%);
  color: #fff3d4;
}

.share-reward-button {
  border: 1px solid rgba(140, 220, 128, 0.55);
  background: linear-gradient(180deg, rgba(140, 220, 128, 0.2) 0%, rgba(72, 146, 69, 0.16) 100%);
  color: #eaffd9;
}

.export-button {
  border: 1px solid rgba(132, 181, 255, 0.55);
  background: linear-gradient(180deg, rgba(132, 181, 255, 0.22) 0%, rgba(73, 110, 185, 0.16) 100%);
  color: #e2edff;
}

.export-button:disabled,
.share-button:disabled,
.share-reward-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

@media (max-width: 640px) {
  .page-shell {
    width: 100%;
    padding: 8px 8px 16px;
  }

  .page-panel {
    padding: 8px;
  }

  .home-panel {
    min-height: calc(100vh - 16px);
    padding: 40px 12px 18px;
  }

  .home-stack {
    gap: 18px;
  }

  .home-card {
    padding: 16px;
  }

  .home-hero-card {
    min-height: 156px;
  }

  .home-hero-logo {
    width: min(126px, 43vw);
  }

  .home-hero-title {
    font-size: clamp(24px, 8vw, 34px);
  }

  .home-action-button {
    min-height: 78px;
    font-size: 22px;
  }

  .page-actions {
    display: grid;
    gap: 14px;
  }

  .share-actions-row {
    gap: 14px;
  }

  .pc-only-action {
    display: none !important;
  }

  .subject-toggle {
    min-height: 54px;
    padding: 8px 38px 8px 10px;
  }

  .waiting-card {
    width: 80px;
  }

  .waiting-thumb {
    width: 80px;
    height: 80px;
  }

  .ranking-mode-bar {
    min-height: 70px;
    padding: 8px 8px 8px 12px;
    gap: 10px;
  }

  .ranking-mode-title {
    font-size: 14px;
  }

  .ranking-mode-logo {
    width: min(96px, 25vw);
    max-width: 42%;
  }

  .app-topbar {
    grid-template-columns: 64px 1fr 64px;
    gap: 8px;
    padding: 8px 10px;
  }

  .topbar-brand {
    gap: 8px;
  }

  .topbar-brand-text {
    font-size: 13px;
  }

  .topbar-brand-logo {
    width: min(78px, 22vw);
  }

  .tier-row {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .tier-badge {
    min-height: 80px;
    font-size: 20px;
  }

  .tier-settings {
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
    gap: 6px;
  }

  .waiting-toolbar {
    display: none !important;
  }
}

@media (min-width: 900px) {
  .home-panel {
    width: min(100%, 860px);
    min-height: calc(100dvh - 36px);
    padding: 64px 34px 24px;
  }

  .home-stack {
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(240px, 0.78fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    gap: 18px;
  }

  .home-card,
  .home-action-button {
    width: calc(100% - 40px);
  }

  .home-hero-card {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 224px;
    padding: 28px 32px;
  }

  .home-hero-logo {
    width: min(174px, 17vw);
  }

  .home-hero-title {
    font-size: clamp(38px, 4.4vw, 56px);
  }

  .home-card-title {
    font-size: 15px;
  }

  .home-subject-card {
    grid-column: 1;
    grid-row: 2;
    min-height: 148px;
    padding: 18px 20px;
  }

  .home-subject-card .subject-toggle {
    min-height: 60px;
  }

  .home-start-button {
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
    min-height: 148px;
    font-size: 28px;
    letter-spacing: 0.06em;
  }
}
