/* Layout for every tycoon-series game. Colours come from the theme's own
   stylesheet through the --ts-* custom properties. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ts-page);
  color: var(--ts-text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  overflow-x: hidden;
}

body.embedded {
  min-height: 0;
}

button,
select {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ts-app {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------------------------------------------------------------- HUD */

.ts-hud {
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: 18px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 25%);
}

.ts-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ts-brand h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  flex: 1;
  color: var(--ts-accent);
}

.ts-brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.ts-icon-missing {
  visibility: hidden;
}

.ts-lang select {
  background: var(--ts-surface-2);
  border: 1px solid var(--ts-line);
  border-radius: 999px;
  padding: 4px 10px;
  max-width: 130px;
}

.ts-cash-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ts-k {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ts-muted);
}

.ts-cash strong {
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  color: var(--ts-text);
}

.ts-income {
  text-align: right;
}

.ts-income strong {
  font-variant-numeric: tabular-nums;
  color: var(--ts-good);
}

.ts-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ts-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--ts-surface-2);
  border: 1px solid var(--ts-line);
  border-radius: 999px;
  padding: 3px 10px 3px 6px;
  font-variant-numeric: tabular-nums;
}

.ts-chip .ts-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.ts-chip .ts-art-missing span,
.ts-brand-icon.ts-art-missing span {
  font-size: 0.72rem;
  color: var(--ts-accent-ink);
  text-shadow: none;
}

.ts-chip .ts-art-missing::after,
.ts-brand-icon.ts-art-missing::after,
.ts-icon.ts-art-missing::after {
  display: none;
}

.ts-date {
  padding-left: 10px;
}

.ts-speed {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
}

.ts-speed-btn {
  --p: 0;
  position: relative;
  min-width: 44px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--ts-line);
  background: var(--ts-surface-2);
  font-weight: 700;
  cursor: pointer;
}

.ts-speed-btn.ts-on {
  background: var(--ts-accent);
  color: var(--ts-accent-ink);
  border-color: var(--ts-accent);
}

.ts-speed-btn.ts-ring::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background: conic-gradient(var(--ts-accent) calc(var(--p) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  pointer-events: none;
}

/* -------------------------------------------------------------- chart */

.ts-chart {
  position: relative;
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: 18px;
  padding: 10px 12px 6px;
  overflow: hidden;
}

.ts-chart-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.ts-chart-head span {
  color: var(--ts-muted);
  font-size: 0.8rem;
}

.ts-chart-head strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.ts-chart-head em {
  font-style: normal;
  font-size: 0.8rem;
  margin-left: auto;
}

.ts-chart canvas {
  display: block;
  width: 100%;
  height: 110px;
}

.ts-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ts-particle {
  position: absolute;
  bottom: 30%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6c8, var(--ts-accent));
  animation: ts-burst 1.1s ease-out forwards;
}

@keyframes ts-burst {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}

.ts-float {
  position: absolute;
  right: 16px;
  top: 40%;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ts-accent);
  text-shadow: 0 2px 8px rgb(0 0 0 / 50%);
  animation: ts-float 1.5s ease-out forwards;
}

@keyframes ts-float {
  to {
    transform: translateY(-50px);
    opacity: 0;
  }
}

.ts-app.ts-loss .ts-chart {
  animation: ts-shake 0.45s ease-in-out;
}

.ts-app.ts-loss::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px 30px rgb(255 40 60 / 55%);
  animation: ts-vignette 0.9s ease-out forwards;
  z-index: 30;
}

@keyframes ts-shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

@keyframes ts-vignette {
  to {
    opacity: 0;
  }
}

/* ------------------------------------------------------ tabs & panels */

.ts-tabs {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--ts-page);
  padding: 4px 0;
}

.ts-tabs::-webkit-scrollbar {
  display: none;
}

/* Tabs size to their label so long words (Propiedades, Investidores) stay whole;
   on the narrowest phones the bar scrolls inside itself, never the page. */
.ts-tab {
  flex: 1 0 auto;
  border: 1px solid var(--ts-line);
  background: var(--ts-surface);
  border-radius: 12px;
  padding: 9px 4px;
  font-size: clamp(0.72rem, 3.3vw, 0.95rem);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.ts-tab[aria-selected="true"] {
  background: var(--ts-accent);
  color: var(--ts-accent-ink);
  border-color: var(--ts-accent);
}

.ts-tab-badge {
  display: inline-block;
  margin-left: 6px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ts-bad);
  color: #fff;
  font-size: 0.75rem;
}

.ts-panel {
  display: grid;
  gap: 12px;
}

.ts-segs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ts-muted);
}

.ts-seg {
  border: 1px solid var(--ts-line);
  background: var(--ts-surface);
  border-radius: 10px;
  padding: 6px 14px;
  cursor: pointer;
}

.ts-seg[aria-pressed="true"] {
  border-color: var(--ts-accent);
  color: var(--ts-accent);
}

.ts-branch {
  border-left: 4px solid var(--branch);
  padding-left: 10px;
}

.ts-branch-name,
.ts-group h2 {
  margin: 4px 0 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ts-group h2 small {
  color: var(--ts-muted);
  font-weight: 400;
}

.ts-locked {
  opacity: 0.75;
}

.ts-lock {
  margin: 0;
  color: var(--ts-muted);
  font-size: 0.85rem;
}

.ts-cards {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.ts-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: 16px;
  padding: 10px;
  min-width: 0;
}

.ts-card-locked {
  filter: grayscale(0.7);
  opacity: 0.7;
}

.ts-card-body {
  min-width: 0;
}

.ts-card h3,
.ts-row h3,
.ts-person h3 {
  margin: 0;
  font-size: 0.98rem;
}

.ts-lv {
  font-size: 0.78rem;
  color: var(--ts-accent);
  margin-left: 4px;
}

.ts-desc,
.ts-sub {
  margin: 2px 0;
  color: var(--ts-muted);
  font-size: 0.8rem;
}

.ts-stats {
  margin: 4px 0;
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.ts-milestone {
  margin: 0 0 4px;
  font-size: 0.75rem;
  color: var(--ts-accent);
}

.ts-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

/* --------------------------------------------------------------- art */

.ts-art,
.ts-portrait,
.ts-event-art,
.ts-icon,
.ts-brand-icon {
  --tile: var(--ts-accent);
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--tile) 70%, #fff 10%), color-mix(in srgb, var(--tile) 35%, var(--ts-surface-2)));
  display: grid;
  place-items: center;
  flex: none;
}

.ts-art img,
.ts-portrait img,
.ts-event-art img,
.ts-icon img,
.ts-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ts-art {
  width: 88px;
  height: 88px;
}

.ts-art-missing span {
  font-size: 1.8rem;
  font-weight: 800;
  color: rgb(255 255 255 / 85%);
  text-shadow: 0 2px 6px rgb(0 0 0 / 35%);
}

.ts-portrait {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.ts-portrait-sm {
  width: 44px;
  height: 44px;
}

.ts-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.ts-icon-lg {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.ts-icon.ts-art-missing span {
  font-size: 0.7rem;
}

.ts-icon-lg.ts-art-missing span {
  font-size: 1rem;
}

/* ------------------------------------------------------- rows, people */

.ts-group {
  display: grid;
  gap: 8px;
}

.ts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: 14px;
  padding: 10px;
}

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

.ts-row .ts-actions {
  margin-top: 0;
}

.ts-row[data-market] .ts-actions {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ts-row[data-market] .ts-btn {
  min-height: 34px;
  padding: 6px 4px;
  font-size: 0.78rem;
}

@media (max-width: 480px) {
  .ts-row[data-market] .ts-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ts-row-price {
  display: grid;
  justify-items: end;
  font-variant-numeric: tabular-nums;
}

.ts-row-price em {
  font-style: normal;
  font-size: 0.78rem;
}

.ts-spark {
  width: 90px;
  height: 26px;
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.ts-spark polyline {
  vector-effect: non-scaling-stroke;
  stroke-width: 2;
}

.ts-spark.ts-up {
  stroke: var(--ts-good);
}

.ts-spark.ts-down {
  stroke: var(--ts-bad);
}

.ts-people {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.ts-person {
  display: flex;
  gap: 10px;
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: 16px;
  padding: 10px;
}

.ts-person > div:last-child {
  flex: 1;
  min-width: 0;
}

.ts-unmet {
  opacity: 0.6;
}

.ts-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--ts-surface-2);
  overflow: hidden;
  margin-top: 6px;
}

.ts-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ts-accent), var(--ts-good));
}

.ts-perks {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 0.78rem;
  color: var(--ts-muted);
}

.ts-captable {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ts-pie {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  flex: none;
}

.ts-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.ts-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
}

.ts-goals {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 3px;
  font-size: 0.88rem;
  color: var(--ts-muted);
}

.ts-goals .ts-done {
  color: var(--ts-good);
  text-decoration: line-through;
}

.ts-reports {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ------------------------------------------------------------ buttons */

.ts-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 38px;
  background: var(--ts-accent);
  color: var(--ts-accent-ink);
  font-weight: 700;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.ts-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ts-btn-quiet {
  background: var(--ts-surface-2);
  color: var(--ts-text);
  border: 1px solid var(--ts-line);
}

.ts-btn-ad {
  background: var(--ts-ad);
  color: #fff;
}

.ts-btn-gold {
  background: linear-gradient(180deg, #ffe38a, var(--ts-accent));
  color: var(--ts-accent-ink);
}

.ts-btn-danger {
  background: var(--ts-bad);
  color: #fff;
}

.ts-link {
  background: none;
  border: 0;
  color: var(--ts-accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}

.ts-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid currentcolor;
  font-size: 0.8rem;
  font-weight: 600;
}

.ts-good {
  color: var(--ts-good);
}

.ts-bad {
  color: var(--ts-bad);
}

.ts-warn {
  color: var(--ts-warn);
}

.ts-gold {
  color: var(--ts-accent);
}

.ts-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  font-size: 0.88rem;
}

.ts-warnbox {
  border-color: var(--ts-warn);
}

.ts-badbox {
  border-color: var(--ts-bad);
}

.ts-notices {
  display: grid;
  gap: 6px;
}

.ts-notices:empty {
  display: none;
}

/* ------------------------------------------------------------- dialog */

.ts-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(3 8 20 / 72%);
  display: grid;
  place-items: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.ts-scrim[hidden] {
  display: none;
}

.ts-sheet {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--ts-surface);
  border: 1px solid var(--ts-accent);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 50%);
  animation: ts-pop 0.22s ease-out;
}

@keyframes ts-pop {
  from {
    transform: translateY(12px) scale(0.97);
    opacity: 0;
  }
}

.ts-sheet h2 {
  margin: 6px 0;
  font-size: 1.25rem;
}

.ts-body {
  margin: 0 0 10px;
  color: var(--ts-muted);
}

.ts-event-art {
  width: 100%;
  height: 150px;
  border-radius: 14px;
}

.ts-cat {
  margin: 10px 0 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ts-accent);
}

.ts-choices {
  display: grid;
  gap: 8px;
}

.ts-choice {
  text-align: left;
  border: 1px solid var(--ts-line);
  background: var(--ts-surface-2);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.ts-choice:hover:not(:disabled),
.ts-choice:focus-visible {
  border-color: var(--ts-accent);
}

.ts-choice:disabled {
  opacity: 0.5;
}

.ts-choice-ad {
  border-color: var(--ts-ad);
}

.ts-fxchips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ts-fxchip {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(255 255 255 / 6%);
  border: 1px solid currentcolor;
}

.ts-fxchip.ts-neutral {
  color: var(--ts-muted);
}

.ts-fxchip.ts-gamble {
  color: var(--ts-warn);
}

.ts-fxchip.ts-ad {
  color: #fff;
  background: var(--ts-ad);
  border-color: var(--ts-ad);
}

.ts-fxchips-lg .ts-fxchip {
  font-size: 0.9rem;
  padding: 4px 10px;
}

.ts-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.ts-ledger {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: grid;
  gap: 6px;
}

.ts-ledger li {
  display: grid;
  grid-template-columns: minmax(90px, 36%) 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.ts-ledger i {
  height: 10px;
  border-radius: 999px;
  background: currentcolor;
}

.ts-ledger b {
  font-variant-numeric: tabular-nums;
}

.ts-grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ts-grade {
  font-size: 2.6rem;
  line-height: 1;
  color: var(--ts-accent);
}

.ts-grade-F,
.ts-grade-D {
  color: var(--ts-bad);
}

.ts-equiv {
  font-weight: 600;
  color: var(--ts-accent);
}

.ts-big {
  font-size: 2rem;
  font-weight: 800;
  margin: 4px 0;
}

.ts-toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  z-index: 40;
  width: min(420px, calc(100% - 24px));
  pointer-events: none;
}

.ts-toast {
  background: var(--ts-surface-2);
  border: 1px solid var(--ts-line);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
  animation: ts-pop 0.2s ease-out;
}

.ts-toast-gold {
  border-color: var(--ts-accent);
  color: var(--ts-accent);
}

.ts-test-ad {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  text-align: center;
  background: #000d;
  color: #fff;
  font: 700 1.2rem system-ui, sans-serif;
}

.ts-test-ad strong {
  font-size: 3rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
