﻿:root { color-scheme: dark; }
    body {
      background: radial-gradient(circle at 20% 10%, #17181c 0%, #050505 45%, #000 100%);
      overflow: hidden;
      font-family: "Rajdhani", "Exo 2", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    }
    * { -webkit-tap-highlight-color: transparent; }
    button, a { touch-action: manipulation; }
    input, textarea, select, button { font-family: inherit; }
    input, textarea, select { font-size: 16px; }

    .app-shell {
      width: 100%;
      height: var(--app-vh, 100dvh);
      overscroll-behavior: contain;
      contain: layout paint style;
      overflow-x: hidden;
    }
    body.desktop-preview .app-shell {
      width: min(430px, calc(100vw - 48px));
      height: min(92dvh, 900px);
      border-radius: 28px;
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    }
    .safe-top { padding-top: calc(env(safe-area-inset-top) + 0.85rem); }
    .safe-bottom { padding-bottom: calc(env(safe-area-inset-bottom) + 0.85rem + var(--kb-offset, 0px)); }
    .safe-y {
      padding-top: calc(env(safe-area-inset-top) + 1.35rem);
      padding-bottom: calc(env(safe-area-inset-bottom) + 1.35rem + var(--kb-offset, 0px));
    }
    body.standalone-mode .safe-top {
      padding-top: calc(max(env(safe-area-inset-top), 30px) + 0.95rem);
    }
    body.standalone-mode .safe-bottom {
      padding-bottom: calc(max(env(safe-area-inset-bottom), 14px) + 0.95rem + var(--kb-offset, 0px));
    }
    body.standalone-mode .safe-y {
      padding-top: calc(max(env(safe-area-inset-top), 30px) + 1.2rem);
      padding-bottom: calc(max(env(safe-area-inset-bottom), 14px) + 1.2rem + var(--kb-offset, 0px));
    }

    body::before {
      content: '';
      position: fixed;
      inset: 0;
      pointer-events: none;
      background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.03) 0px,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 2px,
        transparent 4px
      );
      opacity: 0.18;
      animation: scanMove 9s linear infinite;
    }

    .theme-card {
      box-shadow: 0 0 0 1px rgba(50, 255, 126, 0.08), inset 0 0 18px rgba(50, 255, 126, 0.03);
      transition: border-color .25s ease, box-shadow .25s ease;
    }
    .theme-card:hover {
      border-color: rgba(50, 255, 126, 0.35);
      box-shadow: 0 0 0 1px rgba(50, 255, 126, 0.22), inset 0 0 22px rgba(50, 255, 126, 0.06);
    }

    .portrait-stage,
    .dragon-stage {
      position: relative;
      border: none;
      border-radius: 0;
      background: transparent;
      overflow: visible;
      isolation: isolate;
    }
    .portrait-stage::before,
    .dragon-stage::before {
      content: '';
      position: absolute;
      inset: 8% 10% 12% 10%;
      background: radial-gradient(circle at center, var(--edge-glow, rgba(50, 255, 126, 0.35)), rgba(255, 255, 255, 0));
      opacity: 0.55;
      filter: blur(14px);
      animation: auraPulse 2.6s ease-in-out infinite;
      pointer-events: none;
      z-index: 0;
    }
    .portrait-stage::after,
    .dragon-stage::after {
      content: none;
    }
    .portrait-art,
    .dragon-art {
      position: relative;
      z-index: 1;
      width: 100%;
      height: 100%;
      object-fit: contain;
      object-position: center bottom;
      pointer-events: none;
    }

    .portrait-aura-mage { --edge-glow: rgba(168, 85, 247, 0.72); }
    .portrait-aura-warrior { --edge-glow: rgba(34, 211, 238, 0.72); }
    .portrait-aura-ranger { --edge-glow: rgba(74, 222, 128, 0.72); }

    .portrait-state-steady::before {
      opacity: 0.52;
    }
    .portrait-state-charged::before {
      opacity: 0.68;
    }
    .portrait-state-wounded::before {
      opacity: 0.7;
      background: radial-gradient(circle at center, rgba(239, 68, 68, 0.72), rgba(255, 255, 255, 0));
    }

    .dragon-state-normal { --edge-glow: rgba(50, 255, 126, 0.52); }
    .dragon-state-hurt { --edge-glow: rgba(34, 197, 94, 0.74); }
    .dragon-state-angry { --edge-glow: rgba(239, 68, 68, 0.84); }
    .dragon-state-defeat { --edge-glow: rgba(45, 212, 191, 0.8); }

    .dragon-art {
      filter: drop-shadow(0 0 10px var(--edge-glow, rgba(50, 255, 126, 0.45)));
      transition: transform 180ms ease, filter 180ms ease;
    }
    .dragon-stage:hover .dragon-art {
      transform: scale(1.02);
    }

    .boss-card {
      position: relative;
      overflow: hidden;
      display: grid;
      grid-template-columns: minmax(0, 1fr) 108px;
      gap: 0.7rem;
      align-items: center;
      padding-right: 0;
    }
    .boss-card-main {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
    }
    .boss-visual-strip {
      display: flex;
      justify-content: center;
      align-items: center;
      pointer-events: none;
      margin-top: 0;
      align-self: center;
    }
    .boss-dragon-chip {
      width: 108px;
      min-width: 108px;
      height: 88px;
      padding: 0;
    }
    .boss-dragon-chip .dragon-art {
      height: 100%;
    }

    .energy-ring-layout {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: center;
      gap: 0.6rem;
    }
    .energy-portrait {
      width: 102px;
      min-height: 128px;
      padding: 0;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
    }
    .energy-portrait .portrait-art {
      height: 118px;
    }

    .runtime-display-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(132px, 40%);
      gap: 0.62rem;
      align-items: stretch;
    }
    .runtime-display-grid.single {
      grid-template-columns: 1fr;
    }
    .runtime-dragon-stage {
      min-height: 152px;
      padding: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding-top: 0.25rem;
    }
    .runtime-dragon-stage .dragon-art {
      height: 118px;
      transform: translateY(-6px);
    }

    .class-option-card {
      position: relative;
      overflow: hidden;
      display: grid !important;
      grid-template-columns: 18px 74px minmax(0, 1fr);
      align-items: start;
      gap: 0.62rem;
    }
    .class-option-card > input[type='radio'] {
      margin-top: 0.22rem;
      flex-shrink: 0;
      justify-self: center;
    }
    .class-option-card.is-selected {
      border-color: rgba(50, 255, 126, 0.76);
      box-shadow: 0 0 0 1px rgba(50, 255, 126, 0.25), inset 0 0 28px rgba(50, 255, 126, 0.08);
      background: linear-gradient(180deg, rgba(11, 23, 19, 0.85), rgba(8, 14, 18, 0.85));
    }
    .class-option-art {
      width: 74px;
      min-width: 74px;
      height: 102px;
      padding: 0;
    }
    .class-option-art .portrait-art {
      height: 100%;
    }
    .class-option-copy {
      min-width: 0;
      align-self: start;
    }
    .class-option-copy p {
      margin: 0;
    }
    .class-option-copy p:first-child {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .class-option-copy p:last-child {
      margin-top: 0.14rem;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      word-break: break-word;
    }

    .settlement-sheet {
      display: flex;
      flex-direction: column;
      gap: 0.65rem;
    }
    .settlement-banner {
      border-radius: 0.85rem;
      border: 1px solid currentColor;
      padding: 0.72rem 0.8rem;
      font-weight: 700;
      letter-spacing: 0.01em;
      line-height: 1.35;
      background: linear-gradient(180deg, rgba(9, 14, 18, 0.96), rgba(8, 12, 16, 0.92));
    }
    .settlement-visual-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.55rem;
      align-items: stretch;
    }
    .settlement-hero-card {
      border: 1px solid #2a2d33;
      border-radius: 0.9rem;
      overflow: hidden;
      background:
        radial-gradient(circle at 50% 0%, rgba(52, 211, 153, 0.08), transparent 48%),
        linear-gradient(180deg, rgba(18, 21, 27, 0.94), rgba(8, 10, 14, 0.96));
      box-shadow: inset 0 0 0 1px rgba(50, 255, 126, 0.03);
      min-width: 0;
    }
    .settlement-portrait-stage,
    .settlement-dragon-stage {
      min-height: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
    }
    .settlement-hero-visual {
      min-height: 160px;
      padding: 0.35rem 0.35rem 0.1rem;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }
    .settlement-portrait-stage .portrait-art {
      height: 156px;
      object-position: center center;
    }
    .settlement-dragon-stage .dragon-art {
      height: 154px;
      object-position: center center;
    }
    .settlement-hero-meta {
      padding: 0.55rem 0.75rem 0.75rem;
      display: flex;
      flex-direction: column;
      gap: 0.05rem;
    }
    .settlement-hero-kicker {
      margin: 0;
      font-size: 0.62rem;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: #94a3b8;
    }
    .settlement-hero-name {
      margin: 0;
      font-size: 0.92rem;
      line-height: 1.25;
      color: #f4f4f5;
      font-weight: 700;
      word-break: break-word;
    }
    .settlement-hero-subtitle {
      margin: 0;
      font-size: 0.68rem;
      line-height: 1.3;
      color: #94a3b8;
      word-break: break-word;
    }
    .settlement-stats-card {
      border: 1px solid #2a2d33;
      border-radius: 0.9rem;
      padding: 0.9rem 0.8rem 0.8rem;
      background: linear-gradient(180deg, rgba(12, 14, 18, 0.94), rgba(7, 9, 12, 0.95));
      box-shadow: inset 0 0 0 1px rgba(50, 255, 126, 0.03);
      display: flex;
      flex-direction: column;
      gap: 0.55rem;
    }
    .settlement-stats-title {
      margin: 0;
      padding: 0.18rem 0 0.08rem;
      font-size: 1.5rem;
      line-height: 1.05;
      font-weight: 800;
      letter-spacing: 0.01em;
    }
    .settlement-stats-title.is-win {
      color: #32ff7e;
      text-shadow: 0 0 12px rgba(50, 255, 126, 0.22);
    }
    .settlement-stats-title.is-loss {
      color: #ff4d4f;
      text-shadow: 0 0 12px rgba(255, 77, 79, 0.2);
    }
    .settlement-stats-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.45rem 0.8rem;
    }
    .settlement-stat-item {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.08rem;
    }
    .settlement-stat-item.wide {
      grid-column: 1 / -1;
    }
    .settlement-stat-item.wide .settlement-stat-value {
      white-space: pre-line;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .settlement-stat-label {
      margin: 0;
      font-size: 0.62rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: #94a3b8;
    }
    .settlement-stat-value {
      margin: 0;
      font-size: 0.8rem;
      line-height: 1.38;
      color: #f4f4f5;
      word-break: break-word;
    }
    .settlement-footnote {
      margin: 0;
      padding-top: 0.45rem;
      border-top: 1px solid rgba(148, 163, 184, 0.16);
      font-size: 0.68rem;
      line-height: 1.35;
      color: #9ca3af;
      text-align: center;
    }
    .settlement-footnote.is-win {
      color: #32ff7e;
      border-top-color: rgba(50, 255, 126, 0.2);
      text-shadow: 0 0 10px rgba(50, 255, 126, 0.2);
    }
    .settlement-footnote.is-loss {
      color: #ff4d4f;
      border-top-color: rgba(255, 77, 79, 0.22);
      text-shadow: 0 0 10px rgba(255, 77, 79, 0.22);
    }

    .terminal-cursor {
      display: inline-block;
      width: 8px;
      height: 1em;
      background: #32ff7e;
      margin-left: 4px;
      vertical-align: -2px;
      animation: blink 1s steps(1) infinite;
    }

    .timer-readout {
      font-variant-numeric: tabular-nums;
      letter-spacing: 0.04em;
      text-shadow: 0 0 22px rgba(50, 255, 126, 0.3);
    }
    .timer-pulse { animation: timerPulse 1.2s ease-in-out infinite; }
    .rune-spin {
      animation: runeSpin 10s linear infinite;
      filter: drop-shadow(0 0 12px rgba(50, 255, 126, 0.25));
    }
    .flow-track {
      background: linear-gradient(90deg, rgba(50,255,126,.1), rgba(50,255,126,.65), rgba(50,255,126,.1));
      background-size: 250% 100%;
      animation: flowTrack 1.8s linear infinite;
    }

    .boss-hp-progress,
    .runtime-progress {
      width: 100%;
      border: none;
      background: transparent;
      appearance: none;
      -webkit-appearance: none;
      overflow: hidden;
      display: block;
    }
    .boss-hp-progress {
      height: 100%;
    }
    .runtime-progress {
      height: 0.28rem;
      border-radius: 999px;
      margin-top: 0.72rem;
    }
    .boss-hp-progress::-webkit-progress-bar,
    .runtime-progress::-webkit-progress-bar {
      background: #27272a;
      border-radius: 999px;
    }
    .boss-hp-progress::-webkit-progress-value {
      background: linear-gradient(90deg, #ff6767, #ef4444);
      border-radius: 999px;
      transition: width .35s ease;
    }
    .runtime-progress::-webkit-progress-value {
      background: linear-gradient(90deg, rgba(50,255,126,.15), rgba(50,255,126,.68), rgba(50,255,126,.15));
      background-size: 240% 100%;
      animation: flowTrack 1.8s linear infinite;
      border-radius: 999px;
    }
    .boss-hp-progress::-moz-progress-bar {
      background: linear-gradient(90deg, #ff6767, #ef4444);
      border-radius: 999px;
    }
    .runtime-progress::-moz-progress-bar {
      background: linear-gradient(90deg, rgba(50,255,126,.15), rgba(50,255,126,.68), rgba(50,255,126,.15));
      border-radius: 999px;
    }

    .timer-focus-shell {
      min-height: 0;
      height: 100%;
    }
    .focus-hidden {
      display: none !important;
    }
    .timer-focus-shell.focus-blackout {
      background: #000;
      border-radius: 0.75rem;
      padding: 0.25rem;
      box-shadow: inset 0 0 0 1px rgba(16, 16, 16, 0.95);
    }
    .focus-boss-panel {
      margin-bottom: 0.48rem;
      border: 1px solid #2a2d33;
      border-radius: 0.72rem;
      padding: 0.42rem 0.54rem;
      background: rgba(8, 10, 14, 0.78);
    }
    .focus-boss-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.45rem;
    }
    .focus-boss-name {
      margin: 0;
      font-size: 0.82rem;
      line-height: 1.2;
      color: #f4f4f5;
      font-weight: 700;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .focus-boss-hp {
      font-size: 0.72rem;
      color: #a1a1aa;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .focus-boss-note {
      margin: 0.2rem 0 0;
      font-size: 0.66rem;
      line-height: 1.28;
      color: #a1a1aa;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .focus-boss-progress {
      margin-top: 0.28rem;
      height: 0.32rem;
      border-radius: 999px;
      overflow: hidden;
    }
    .focus-card-stage {
      width: 100%;
      --focus-landscape-scale: 1;
    }
    .focus-card-stage.focus-orientation-portrait .focus-card-shell {
      position: static;
      transform: none;
      margin: 0;
    }
    .focus-card-stage.focus-orientation-landscape {
      position: relative;
      width: 100%;
      height: 100%;
      min-height: 320px;
      border: 1px solid #23262a;
      border-radius: 0.75rem;
      overflow: hidden;
      background: #050505;
    }
    .focus-card-stage.focus-orientation-landscape .focus-card-shell {
      position: absolute;
      left: 50%;
      top: 50%;
      width: min(94%, 560px);
      transform: translate(-50%, -50%) rotate(90deg) scale(var(--focus-landscape-scale));
      transform-origin: center center;
      margin: 0;
    }
    .focus-card-stage.focus-orientation-landscape .focus-boss-panel {
      margin-bottom: 0.34rem;
      padding: 0.34rem 0.45rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-boss-name {
      font-size: 0.74rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-boss-hp {
      font-size: 0.64rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-boss-note {
      font-size: 0.6rem;
      margin-top: 0.14rem;
      -webkit-line-clamp: 1;
    }
    .focus-card-stage.focus-orientation-landscape .focus-boss-progress {
      margin-top: 0.2rem;
      height: 0.26rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-layout {
      display: grid;
      grid-template-columns: minmax(0, 1.6fr) minmax(112px, 0.72fr);
      gap: 0.45rem;
      align-items: stretch;
      margin-top: 0.35rem;
    }
    .focus-card-stage.focus-orientation-landscape #runtimePanel {
      min-height: 186px;
      margin-top: 0;
      padding: 0.58rem;
      display: flex;
      flex-direction: column;
      justify-content: center;
      overflow: hidden;
    }
    .focus-card-stage.focus-orientation-landscape .timer-readout {
      font-size: clamp(1.58rem, 4.4vw, 2.65rem) !important;
      line-height: 0.98;
      margin-top: 0.16rem;
      white-space: nowrap;
      letter-spacing: 0;
    }
    .focus-card-stage.focus-orientation-landscape .timer-readout-landscape {
      font-size: clamp(1.5rem, 4.2vw, 2.52rem) !important;
    }
    .focus-card-stage.focus-orientation-landscape .runtime-subtitle {
      font-size: 0.66rem;
      line-height: 1.18;
      margin-top: 0.18rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .focus-card-stage.focus-orientation-landscape .runtime-extra {
      margin-top: 0.45rem;
    }
    .focus-card-stage.focus-orientation-landscape .runtime-extra .w-10,
    .focus-card-stage.focus-orientation-landscape .runtime-extra .h-10 {
      width: 2rem;
      height: 2rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-decor {
      display: flex;
      flex-direction: column;
      gap: 0.45rem;
      justify-content: stretch;
    }
    .focus-card-stage.focus-orientation-landscape .focus-side-btn,
    .focus-card-stage.focus-orientation-landscape .focus-main-btn {
      width: 100%;
      min-height: 36px;
      margin-top: 0;
      font-size: 0.72rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-main-btn {
      margin-top: auto;
      min-height: 44px;
      font-size: 0.78rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-card-shell h3 {
      margin-bottom: 0.35rem;
      font-size: 1.2rem;
      line-height: 1;
    }
    .focus-card-stage.focus-orientation-landscape .focus-black-hint { display: none !important; }
    .focus-card-stage.focus-orientation-landscape .focus-top-actions {
      margin-bottom: 0.34rem;
    }
    .focus-card-stage.focus-orientation-landscape .focus-wake-toggle {
      margin-bottom: 0.34rem;
      min-height: 34px;
      font-size: 0.66rem;
      line-height: 1.15;
      padding-top: 0.36rem;
      padding-bottom: 0.36rem;
    }

    .focus-hold-stop-btn {
      position: relative;
      overflow: hidden;
      white-space: nowrap;
      flex-shrink: 0;
      background: rgba(127, 29, 29, 0.12);
      color: #fca5a5;
      --hold-progress: 0;
      transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
    }
    .focus-hold-stop-btn::before {
      content: '';
      position: absolute;
      inset: 0;
      width: calc(var(--hold-progress) * 100%);
      background: linear-gradient(90deg, rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.5));
      pointer-events: none;
      transition: width 60ms linear;
    }
    .focus-hold-stop-btn.is-holding {
      border-color: rgba(239, 68, 68, 0.95);
      color: #fecaca;
      background: rgba(127, 29, 29, 0.2);
      box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
    }
    .focus-card-stage.focus-orientation-landscape .focus-hold-stop-btn {
      font-size: 0.66rem;
      padding-top: 0.34rem;
      padding-bottom: 0.34rem;
    }

    .focus-black {
      background: #000 !important;
      border-color: #101010 !important;
      box-shadow: none !important;
    }
    .focus-black .focus-boss-panel {
      background: #020202;
      border-color: #111216;
      box-shadow: none;
    }
    .focus-black .focus-boss-name {
      color: #d4d4d8;
    }
    .focus-black .focus-boss-hp,
    .focus-black .focus-boss-note {
      color: #71717a;
    }
    .focus-black .focus-decor { display: none; }
    .focus-black-hint { display: none; }
    .focus-black .focus-black-hint { display: block; }

    .runtime-class-stage {
      min-height: 152px;
      padding-top: 0.2rem;
    }
    .runtime-class-stage .portrait-art {
      height: 118px;
      transform: translateY(-4px);
    }

    .hdr-boost .timer-readout {
      text-shadow: 0 0 26px rgba(50, 255, 126, 0.6), 0 0 42px rgba(50, 255, 126, 0.35);
    }
    .hdr-boost .focus-main-btn {
      box-shadow: 0 0 20px rgba(50, 255, 126, 0.35), inset 0 0 18px rgba(50, 255, 126, 0.16);
    }

    .main-footer {
      overflow-x: hidden;
      overscroll-behavior-x: contain;
      touch-action: pan-y;
    }
    .action-strip {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.5rem;
      overflow: visible;
      padding-bottom: 0;
    }
    .action-strip button {
      min-width: 0;
      width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .action-strip button.inbox-notify-btn {
      position: relative;
      overflow: visible;
    }
    .inbox-unread-badge {
      position: absolute;
      top: -0.38rem;
      right: -0.34rem;
      min-width: 1.1rem;
      height: 1.1rem;
      padding: 0 0.22rem;
      border-radius: 999px;
      border: 1px solid rgba(248, 113, 113, 0.78);
      background: #ef4444;
      color: #fff;
      font-size: 0.61rem;
      line-height: 1;
      font-weight: 700;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 0 0 1px rgba(6, 8, 12, 0.86), 0 5px 12px rgba(239, 68, 68, 0.42);
      pointer-events: none;
      z-index: 2;
    }
    @media (min-width: 520px) {
      .action-strip {
        grid-template-columns: repeat(4, minmax(0, 1fr));
      }
    }

    @keyframes blink {
      0%, 49% { opacity: 1; }
      50%, 100% { opacity: 0; }
    }
    @keyframes scanMove {
      0% { transform: translateY(-6px); }
      100% { transform: translateY(6px); }
    }
    @keyframes timerPulse {
      0%, 100% { transform: scale(1); opacity: .85; }
      50% { transform: scale(1.02); opacity: 1; }
    }
    @keyframes runeSpin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }
    @keyframes flowTrack {
      0% { background-position: 0 0; }
      100% { background-position: 100% 0; }
    }
    @keyframes auraPulse {
      0%, 100% { opacity: 0.72; transform: scale(1); }
      50% { opacity: 1; transform: scale(1.012); }
    }

    @media (hover: none) and (pointer: coarse) {
      body::before {
        animation: none;
        opacity: 0.06;
      }
      .theme-card:hover {
        border-color: #23262a;
        box-shadow: 0 0 0 1px rgba(50, 255, 126, 0.08), inset 0 0 18px rgba(50, 255, 126, 0.03);
      }
      .timer-pulse,
      .rune-spin,
      .flow-track {
        animation-duration: 2.4s;
      }
      .portrait-stage::after,
      .dragon-stage::after {
        animation-duration: 4.2s;
      }
    }

    @media (max-width: 430px) {
      .energy-ring-layout {
        grid-template-columns: 74px minmax(0, 1fr) 68px;
        gap: 0.38rem;
      }
      .energy-portrait {
        grid-column: auto;
        justify-self: end;
        width: 68px;
        min-height: 94px;
      }
      .energy-portrait .portrait-art {
        height: 84px;
      }
      .runtime-display-grid {
        grid-template-columns: minmax(0, 1fr) minmax(118px, 36%);
      }
      .runtime-dragon-stage .dragon-art {
        height: 96px;
      }
      .boss-card {
        grid-template-columns: minmax(0, 1fr) 92px;
        gap: 0.45rem;
      }
      .boss-dragon-chip {
        width: 92px;
        min-width: 92px;
        height: 78px;
      }
      .class-option-card {
        grid-template-columns: 16px 62px minmax(0, 1fr);
        gap: 0.46rem;
      }
      .class-option-art {
        width: 62px;
        min-width: 62px;
        height: 86px;
      }
      .class-option-copy p:first-child {
        font-size: 0.8rem;
      }
      .class-option-copy p:last-child {
        font-size: 0.66rem;
        -webkit-line-clamp: 2;
      }
      .template-message-field {
        grid-template-columns: 1fr;
        gap: 0.25rem;
      }
      .template-message-label {
        white-space: normal;
      }
      .settlement-visual-grid {
        grid-template-columns: 1fr;
      }
      .settlement-hero-visual {
        min-height: 150px;
      }
      .settlement-portrait-stage .portrait-art,
      .settlement-dragon-stage .dragon-art {
        height: 128px;
      }
      .settlement-stats-grid {
        grid-template-columns: 1fr;
      }
    }
    @media (dynamic-range: high) {
      .hdr-boost .timer-readout { color: color(display-p3 0.28 1 0.62); }
      .hdr-boost .focus-main-btn { border-color: color(display-p3 0.28 1 0.62); }
    }

    body.power-save::before { display: none; }
    body.power-save *,
    body.power-save *::before,
    body.power-save *::after {
      animation: none !important;
      transition: none !important;
    }

    /* Mobile-first game sheet modal */
    #modal {
      align-items: flex-end;
      justify-content: center;
      padding: 0.6rem;
      padding-bottom: calc(env(safe-area-inset-bottom) + 0.6rem + var(--kb-offset, 0px));
      overflow: hidden;
    }
    #modalCard {
      width: min(100%, 520px);
      max-height: calc(var(--app-vh, 100dvh) - 1.2rem);
      border-radius: 1rem;
      border-color: #2a2d33;
      background:
        radial-gradient(circle at 22% 0%, rgba(52, 211, 153, 0.14), transparent 48%),
        linear-gradient(180deg, rgba(20, 22, 28, 0.98), rgba(10, 12, 16, 0.98));
      display: flex;
      flex-direction: column;
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
      overflow: hidden;
    }
    #modalTitle {
      font-size: 1rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      margin-bottom: 0.45rem;
    }
    #modalBody {
      overflow: auto;
      -webkit-overflow-scrolling: touch;
      flex: 1;
      min-height: 0;
      padding-right: 0.1rem;
    }
    #modalActions {
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      padding-top: 0.45rem;
      margin-top: 0.45rem;
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
      justify-content: flex-end;
      background: linear-gradient(180deg, rgba(10, 12, 16, 0), rgba(10, 12, 16, 0.82));
    }
    #modalActions button {
      min-height: 36px;
      min-width: 88px;
      flex: 1;
      letter-spacing: 0.02em;
    }

    .ui-panel {
      border: 1px solid #2a2d33;
      border-radius: 0.82rem;
      padding: 0.5rem;
      background: linear-gradient(180deg, rgba(33, 37, 45, 0.72), rgba(14, 16, 22, 0.72));
      box-shadow: inset 0 0 0 1px rgba(50, 255, 126, 0.03);
    }
    .modal-shell {
      opacity: 0;
      transform: translateY(6px);
      transition: opacity 160ms ease, transform 160ms ease;
      will-change: opacity, transform;
    }
    .modal-shell.is-visible {
      opacity: 1;
      transform: translateY(0);
    }
    .social-modal-frame {
      min-height: 0;
      max-height: 68dvh;
    }
    .ui-panel-title {
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      font-weight: 700;
    }
    .ui-panel-subtitle {
      margin-top: 0.1rem;
      font-size: 0.68rem;
      color: #94a3b8;
    }

    .modal-tabs {
      display: flex;
      gap: 0.28rem;
      overflow-x: auto;
      padding-bottom: 0.1rem;
      scrollbar-width: none;
    }
    .modal-tabs::-webkit-scrollbar {
      display: none;
    }
    .modal-tab {
      flex: 1 1 0;
      min-width: 0;
      min-height: 30px;
      padding: 0.26rem 0.48rem;
      border-radius: 0.8rem;
      border: 1px solid #2a2d33;
      background: rgba(10, 12, 16, 0.72);
      color: #d4d4d8;
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: 0.02em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease, transform 120ms ease;
    }
    .modal-tab:active {
      transform: translateY(1px);
    }
    .modal-tab.active {
      border-color: rgba(50, 255, 126, 0.72);
      color: #4ade80;
      background: rgba(50, 255, 126, 0.12);
      box-shadow: 0 0 0 1px rgba(50, 255, 126, 0.08);
    }
    .tab-count {
      margin-left: 0.18rem;
      font-size: 0.6rem;
      opacity: 0.62;
    }

    .compact-summary-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.45rem;
    }
    .compact-summary-card {
      border: 1px solid #2a2d33;
      border-radius: 0.8rem;
      padding: 0.55rem 0.6rem;
      background: rgba(8, 10, 14, 0.75);
    }
    .compact-summary-label {
      font-size: 0.63rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: #94a3b8;
    }
    .compact-summary-value {
      margin-top: 0.15rem;
      font-size: 0.92rem;
      font-weight: 700;
      color: #f4f4f5;
      line-height: 1.2;
    }

    .compact-toolbar {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 0.45rem;
      align-items: center;
    }
    .compact-toolbar.split {
      grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    }

    .rank-nav-grid {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
      gap: 0.45rem;
      align-items: center;
    }

    .compact-empty {
      border: 1px dashed #30333a;
      border-radius: 0.8rem;
      padding: 0.5rem;
      text-align: center;
      color: #94a3b8;
      font-size: 0.68rem;
      background: rgba(8, 10, 14, 0.45);
    }

    .message-preview {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .message-pill {
      font-size: 0.61rem;
      color: #a1a1aa;
      border: 1px solid #2a2d33;
      border-radius: 999px;
      padding: 0.1rem 0.4rem;
      background: rgba(8, 10, 14, 0.55);
      white-space: nowrap;
    }

    .month-switch {
      display: grid;
      grid-template-columns: auto 1fr auto;
      align-items: center;
      gap: 0.45rem;
    }
    .month-nav-btn {
      min-height: 38px;
      border: 1px solid #2a2d33;
      border-radius: 0.7rem;
      padding: 0 0.75rem;
      color: #e4e4e7;
      background: rgba(10, 12, 16, 0.7);
    }
    .month-nav-btn:active {
      transform: translateY(1px);
    }

    .rank-list,
    .social-list,
    .inbox-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.28rem;
    }
    .rank-row,
    .social-row,
    .inbox-row {
      border: 1px solid #2a2d33;
      border-radius: 0.66rem;
      padding: 0.38rem 0.5rem;
      background: rgba(8, 10, 14, 0.72);
      transition: border-color 120ms ease, background-color 120ms ease;
      min-width: 0;
    }
    .rank-row {
      display: grid;
      grid-template-columns: auto 1fr auto;
      gap: 0.36rem;
      align-items: start;
    }
    .rank-badge {
      min-width: 36px;
      height: 22px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 0.66rem;
      font-weight: 700;
      border: 1px solid #374151;
      background: rgba(55, 65, 81, 0.45);
      color: #e5e7eb;
    }
    .rank-name {
      min-width: 0;
      font-size: 0.8rem;
      color: #f4f4f5;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .rank-name-block {
      min-width: 0;
      display: grid;
      gap: 0.06rem;
    }
    .rank-meta {
      min-width: 0;
      font-size: 0.6rem;
      color: #94a3b8;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .rank-boss {
      min-width: 0;
      font-size: 0.62rem;
      color: #cbd5e1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .rank-score {
      font-size: 0.68rem;
      padding: 0.12rem 0.34rem;
      border-radius: 999px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      white-space: nowrap;
    }
    .rank-row-actions {
      justify-content: flex-end;
      flex-wrap: wrap;
      row-gap: 0.22rem;
      align-self: start;
    }

    @media (max-width: 540px) {
      .rank-row {
        grid-template-columns: auto minmax(0, 1fr);
        row-gap: 0.26rem;
      }
      .rank-row-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        padding-left: 2.05rem;
      }
      .rank-score {
        font-size: 0.64rem;
      }
    }

    .social-search {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 0.45rem;
      margin-top: 0.55rem;
    }
    .social-row {
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      align-items: stretch;
    }
    .social-main {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
    }
    .social-title {
      margin: 0;
      font-size: 0.78rem;
      line-height: 1.25;
      color: #f4f4f5;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .social-meta {
      margin: 0;
      font-size: 0.64rem;
      line-height: 1.25;
      color: #94a3b8;
    }
    .social-actions {
      display: flex;
      gap: 0.3rem;
      align-items: center;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-self: stretch;
    }

    .template-message-panel {
      display: flex;
      flex-direction: column;
      gap: 0.45rem;
    }
    .template-message-body {
      display: flex;
      flex-direction: column;
      gap: 0.45rem;
    }
    .template-message-field {
      display: grid;
      grid-template-columns: minmax(4.6rem, auto) minmax(0, 1fr);
      gap: 0.45rem;
      align-items: center;
    }
    .template-message-label {
      margin: 0;
      font-size: 0.72rem;
      color: #a1a1aa;
      line-height: 1.2;
      white-space: nowrap;
    }
    .template-message-select {
      min-height: 42px;
      padding: 0.5rem 0.65rem;
      line-height: 1.15;
    }
    .template-message-preview {
      border: 1px solid #2a2d33;
      border-radius: 0.75rem;
      padding: 0.55rem 0.65rem;
      background: rgba(8, 10, 14, 0.68);
      font-size: 0.74rem;
      line-height: 1.3;
      min-height: 2.8rem;
    }
    .template-message-error {
      min-height: 1.1em;
      margin: 0;
    }

    .inbox-row {
      display: grid;
      gap: 0.26rem;
      align-items: start;
    }
    .inbox-head {
      display: flex;
      justify-content: space-between;
      gap: 0.4rem;
      align-items: flex-start;
      font-size: 0.66rem;
      line-height: 1.2;
      color: #a1a1aa;
    }
    .inbox-content {
      margin: 0;
      font-size: 0.78rem;
      line-height: 1.28;
      color: #f4f4f5;
      word-break: break-word;
    }

    @media (prefers-reduced-motion: reduce) {
      .modal-shell {
        opacity: 1;
        transform: none;
        transition: none;
      }
      .portrait-stage::after,
      .dragon-stage::after,
      .dragon-art {
        animation: none !important;
        transition: none !important;
      }
    }

    @media (min-width: 640px) {
      #modal {
        align-items: center;
        padding: 1rem;
      }
      #modalCard {
        max-height: min(88dvh, 860px);
      }
      #modalActions button {
        flex: 0 0 auto;
      }
    }

    body.modal-open {
      overflow: hidden;
      touch-action: pan-y;
    }

    .app-page {
      height: 100%;
      overflow: auto;
      padding: 1.05rem;
      -webkit-overflow-scrolling: touch;
    }
    .page-stack {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
    }
    .page-hero {
      border: 1px solid #2a2d33;
      border-radius: 1rem;
      padding: 0.95rem;
      background:
        radial-gradient(circle at 18% 0%, rgba(52, 211, 153, 0.12), transparent 46%),
        linear-gradient(180deg, rgba(28, 31, 38, 0.9), rgba(10, 12, 16, 0.9));
      box-shadow: inset 0 0 0 1px rgba(50, 255, 126, 0.04);
    }
    .page-kicker {
      font-size: 0.67rem;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: #71717a;
    }
    .page-title {
      margin-top: 0.2rem;
      font-size: 1.2rem;
      line-height: 1.2;
      font-weight: 700;
      letter-spacing: 0.03em;
      color: #f4f4f5;
    }
    .page-subtitle {
      margin-top: 0.35rem;
      font-size: 0.82rem;
      line-height: 1.45;
      color: #a1a1aa;
    }

    .game-card {
      border: 1px solid #2a2d33;
      border-radius: 0.95rem;
      padding: 0.82rem;
      background: linear-gradient(180deg, rgba(24, 27, 34, 0.88), rgba(9, 11, 14, 0.88));
      box-shadow: inset 0 0 0 1px rgba(50, 255, 126, 0.03);
    }
    .card-title {
      font-size: 0.88rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: #e4e4e7;
    }
    .card-subtitle {
      margin-top: 0.25rem;
      font-size: 0.73rem;
      color: #94a3b8;
      line-height: 1.4;
    }

    .field-label {
      display: block;
      margin-bottom: 0.35rem;
      font-size: 0.78rem;
      color: #d4d4d8;
      letter-spacing: 0.02em;
    }
    .input-core,
    .textarea-core,
    .select-core {
      width: 100%;
      border: 1px solid #2a2d33;
      border-radius: 0.78rem;
      background: rgba(11, 13, 18, 0.9);
      color: #f4f4f5;
      padding: 0.72rem 0.8rem;
      outline: none;
      transition: border-color .22s ease, box-shadow .22s ease;
    }
    .textarea-core {
      resize: none;
      min-height: 78px;
      line-height: 1.45;
    }
    .input-core:focus,
    .textarea-core:focus,
    .select-core:focus {
      border-color: rgba(74, 222, 128, 0.85);
      box-shadow: 0 0 0 1px rgba(50, 255, 126, 0.22), 0 0 0 4px rgba(50, 255, 126, 0.08);
    }

    .btn-main,
    .btn-sub,
    .btn-ghost,
    .btn-alert {
      min-height: 44px;
      border-radius: 0.78rem;
      border: 1px solid #2a2d33;
      font-size: 0.82rem;
      letter-spacing: 0.02em;
      font-weight: 600;
      padding: 0.62rem 0.86rem;
      transition: transform .12s ease, border-color .2s ease, background-color .2s ease;
    }
    .btn-main {
      border-color: rgba(52, 211, 153, 0.65);
      color: #4ade80;
      background: rgba(52, 211, 153, 0.14);
    }
    .btn-main:hover { background: rgba(52, 211, 153, 0.2); }
    .btn-sub {
      border-color: #2f333a;
      color: #f4f4f5;
      background: rgba(18, 21, 28, 0.78);
    }
    .btn-sub:hover,
    .btn-ghost:hover {
      border-color: rgba(74, 222, 128, 0.58);
      color: #86efac;
    }
    .btn-ghost {
      border-color: #2f333a;
      color: #e4e4e7;
      background: transparent;
    }
    .btn-alert {
      border-color: rgba(248, 113, 113, 0.72);
      color: #f87171;
      background: rgba(248, 113, 113, 0.14);
    }
    .btn-main:active,
    .btn-sub:active,
    .btn-ghost:active,
    .btn-alert:active {
      transform: translateY(1px);
    }

    .status-text {
      font-size: 0.73rem;
      line-height: 1.4;
      color: #94a3b8;
      min-height: 1.1rem;
    }
    .status-text.error {
      color: #fb7185;
    }
    .status-text.ok {
      color: #4ade80;
    }
