:root {
  color-scheme: dark;
  --bg: #0a0d14;
  --panel: #141922;
  --panel-2: #1a2030;
  --border: #2a3348;
  --text: #eef2ff;
  --muted: #9aa6bf;
  --primary: #3373b3;
  --success: #40995a;
  --accent: #734d26;
  --danger: #993333;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at top, #121826 0%, var(--bg) 55%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.screen {
  min-height: 100vh;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 28px;
  position: relative;
  top: 12vh;
  background: rgba(20, 25, 34, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.login-card h1,
.modal-card h2,
.mine-panel h2,
.side-panel h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.subtitle {
  margin: 0 0 8px;
  color: var(--muted);
}

.tagline {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #252b3a;
  color: var(--text);
}

input:focus {
  outline: 2px solid rgba(51, 115, 179, 0.5);
  border-color: var(--primary);
}

select {
  width: 100%;
  padding: 12px 40px 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: #252b3a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 5l4 4 4-4' stroke='%239aa6bf' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color-scheme: dark;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:hover {
  border-color: #3a4660;
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(51, 115, 179, 0.35);
}

select option,
select optgroup {
  background-color: var(--panel);
  color: var(--text);
}

.birthday-selects {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 8px;
}

.birthday-selects input {
  width: 100%;
}

.register-profile-group {
  margin-top: 0.25rem;
}

.register-profile-group select {
  width: 100%;
  margin-bottom: 0.35rem;
}

.register-language-hint,
.register-field-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted, #8b9cb3);
  line-height: 1.4;
}

.register-privacy-options,
.profile-privacy-options {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
}

.register-privacy-option,
.profile-privacy-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
  cursor: pointer;
}

.register-privacy-option input,
.profile-privacy-option input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.profile-public-info {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--muted, #8b9cb3);
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  color: white;
  background: #3a4258;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn.primary { background: var(--primary); }
.btn.success { background: var(--success); }
.btn.accent { background: var(--accent); }
.btn.danger { background: var(--danger); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

#toggle-mode {
  width: 100%;
  margin-top: 10px;
}

.status-text,
.status-bar {
  min-height: 1.25rem;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: #ffb380;
}

.status-text:empty,
.status-bar:empty {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.status-text.info,
.status-bar.info {
  color: #c8d4f0;
  background: rgba(51, 115, 179, 0.12);
  border-color: rgba(51, 115, 179, 0.35);
}

.status-text.success,
.status-bar.success {
  color: #9fd9ad;
  background: rgba(64, 153, 90, 0.15);
  border-color: rgba(64, 153, 90, 0.45);
}

.status-text.error,
.status-bar.error {
  color: #ffb3aa;
  background: rgba(153, 51, 51, 0.18);
  border-color: rgba(153, 51, 51, 0.45);
}

.api-status {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  text-align: center;
}

.api-status.checking {
  color: var(--muted);
}

.api-status.online {
  color: var(--success);
}

.api-status.degraded {
  color: #e6b84d;
}

.api-status.error {
  color: #ffb3aa;
}

.ban-appeal-notice {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(153, 51, 51, 0.15);
  border: 1px solid rgba(153, 51, 51, 0.35);
  color: #ffb3aa;
}

.moderation-modal-card {
  max-width: 520px;
}

.moderation-modal-message {
  margin: 12px 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.moderation-modal-meta {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.moderation-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.register-tos-gate {
  display: none !important;
  gap: 14px;
  margin: 8px 0 4px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
}

.register-tos-gate.register-tos-gate--visible {
  display: grid !important;
}

.login-card[data-auth-mode="register"] .register-tos-gate.register-tos-gate--visible {
  display: grid !important;
}

.login-card:not([data-auth-mode="register"]) .register-tos-gate {
  display: none !important;
}

.register-tos-intro {
  margin: 0;
  line-height: 1.5;
}

.register-tos-open-control {
  display: block;
  align-self: start;
  max-width: 100%;
}

.register-tos-open-btn {
  width: 100%;
  white-space: normal;
  text-align: left;
}

.register-tos-open-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
}

.register-tos-panel {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
}

.register-tos-panel[hidden] {
  display: none !important;
}

.register-tos-panel-title {
  margin: 0;
  font-size: 1.05rem;
}

.register-tos-done-btn {
  justify-self: start;
}

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

.register-form-shell {
  display: grid;
  gap: 0;
}

.register-form-shell[hidden] {
  display: none !important;
}

.register-tos-body {
  max-height: min(360px, 50vh);
  overflow: auto;
  padding-right: 4px;
  line-height: 1.55;
}

.register-tos-body section {
  margin-bottom: 16px;
}

.register-tos-body h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.register-tos-body p {
  margin: 0;
  color: var(--muted);
}

#ban-appeal-group label {
  display: block;
  margin-top: 12px;
}

#ban-appeal-message {
  width: 100%;
  min-height: 96px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  resize: vertical;
}

#ban-appeal-btn {
  width: 100%;
  margin-top: 10px;
}

.auth-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 4000;
  width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%) translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.auth-toast.success {
  color: #d7f5de;
  background: rgba(24, 58, 34, 0.96);
  border-color: rgba(64, 153, 90, 0.65);
}

.auth-toast.error {
  color: #ffd8d3;
  background: rgba(58, 24, 24, 0.96);
  border-color: rgba(153, 51, 51, 0.65);
}

.hud {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 20px;
  background: rgba(15, 20, 28, 0.95);
  border-bottom: 1px solid var(--border);
}

#game-screen:not([hidden]) {
  display: flex;
  min-height: 100vh;
}

#game-screen[hidden] {
  display: none !important;
}

.game-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 148px;
  flex-shrink: 0;
  padding: 14px 10px;
  background: rgba(10, 14, 20, 0.98);
  border-right: 1px solid var(--border);
}

.game-nav .btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.exonet-tab {
  border-color: rgba(100, 180, 255, 0.35);
  color: #9fd4ff;
  background: rgba(20, 40, 70, 0.45);
}

.game-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.hud-left {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.rax-value {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.rax-icon {
  width: 1em;
  height: 1.35em;
  object-fit: contain;
  vertical-align: middle;
  flex-shrink: 0;
}

.rax-amount {
  font-variant-numeric: tabular-nums;
}

.rax-name {
  color: var(--muted);
  font-size: 0.92em;
  margin-left: 0.15rem;
}

.rax-hud-balance .rax-icon {
  width: 1.1em;
  height: 1.45em;
}

.utc-clock {
  color: var(--muted);
  font-size: 0.9rem;
}

.player-name {
  font-weight: 600;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 18px;
  padding: 18px;
  max-width: 1400px;
  margin: 0 auto;
}

.mine-panel,
.side-panel {
  background: rgba(20, 25, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.mine-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 8), 1fr);
  gap: 4px;
  aspect-ratio: 1;
  margin-top: 12px;
}

.zone-cell {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  cursor: pointer;
  min-height: 0;
}

.zone-cell.selected {
  outline: 2px solid white;
  outline-offset: 1px;
}

.zone-info {
  line-height: 1.6;
  color: var(--muted);
  min-height: 96px;
}

.side-panel h3 {
  margin: 18px 0 10px;
  font-size: 1rem;
}

.worker-list,
.shop-list,
.transaction-list {
  display: grid;
  gap: 8px;
}

.worker-btn,
.shop-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #252f42;
  color: var(--text);
  cursor: pointer;
}

.worker-btn.assigned {
  background: #3d6647;
}

.worker-btn.busy {
  opacity: 0.65;
}

.shop-btn {
  display: grid;
  gap: 4px;
}

.shop-btn span {
  color: var(--muted);
  font-size: 0.9rem;
}

.summary {
  line-height: 1.7;
  margin-bottom: 16px;
}

.summary .danger {
  color: #ff8877;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 3000;
}

.modal[hidden] {
  display: none !important;
}

body:not(.is-authenticated) .modal {
  display: none !important;
}

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.market-info {
  color: var(--muted);
  margin-bottom: 16px;
}

.shop-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.auction-panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.auction-create-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.auction-create-form label {
  margin: 0 0 4px;
}

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

.auction-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.18);
}

.auction-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.auction-card-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.auction-bid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.auction-bid-row input {
  width: 120px;
}

.trade-market-value {
  font-weight: 600;
}

.day-report {
  white-space: pre-wrap;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 14px;
  min-height: 120px;
}

.event-modal-card {
  max-width: 420px;
}

.event-modal-challenge {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(77, 204, 128, 0.12);
  border: 1px solid rgba(77, 204, 128, 0.35);
  line-height: 1.5;
}

.event-modal-rewards-heading {
  margin: 0 0 10px;
  font-size: 1rem;
}

.event-modal-message {
  margin: 0 0 14px;
  line-height: 1.5;
  color: var(--muted);
}

.event-rewards-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.event-rewards-list li {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.required {
  color: #ff8877;
}

.linkish {
  margin-top: 6px;
  font-size: 0.9rem;
}

.game-version {
  position: fixed;
  right: 16px;
  bottom: 12px;
  z-index: 20;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
}

#login-screen[hidden] ~ .game-version {
  display: none;
}

#reset-group label {
  margin-top: 12px;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #111;
  font-size: 0.72rem;
  font-weight: 700;
}

.staff-message-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 16px;
  min-height: 320px;
}

.staff-message-inbox,
.staff-message-detail {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

.staff-message-inbox {
  display: grid;
  align-content: start;
  max-height: 480px;
  overflow: auto;
}

.staff-message-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.staff-message-item:last-child {
  border-bottom: 0;
}

.staff-message-item.unread {
  background: rgba(51, 115, 179, 0.14);
}

.staff-message-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.staff-message-from {
  font-weight: 700;
}

.staff-message-type {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.player-message-compose {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.player-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

#player-peer-panel > .player-message-actions {
  margin-top: 28px;
  margin-bottom: 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

#player-staff-panel > .player-message-actions {
  margin-top: 12px;
  margin-bottom: 16px;
  padding-top: 0;
  border-top: none;
}

#messages-modal #messages-status {
  margin: 0 0 4px;
}

.player-staff-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.player-messages-panel .staff-message-layout {
  margin-top: 0;
}

.player-message-compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-message-compose-head h3 {
  margin: 0;
}

.player-message-compose:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.player-message-compose h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.player-message-compose label {
  font-size: 0.85rem;
  font-weight: 600;
}

.player-message-compose select,
.player-message-compose textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
}

.player-message-compose select {
  padding-right: 40px;
  background-color: #252b3a;
  color-scheme: dark;
}

.player-message-compose select option {
  background-color: var(--panel);
  color: var(--text);
}

.player-message-compose textarea {
  min-height: 80px;
  resize: vertical;
}

.staff-message-preview,
.staff-message-date,
.staff-message-detail-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.staff-message-detail {
  padding: 16px 18px;
}

.staff-message-detail-top h3 {
  margin: 0 0 6px;
}

.staff-message-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.staff-message-detail-head .btn {
  flex-shrink: 0;
}

.staff-message-detail-body {
  margin-top: 16px;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .staff-message-layout {
    grid-template-columns: 1fr;
  }

  .game-layout,
  .shop-columns {
    grid-template-columns: 1fr;
  }

  #game-screen:not([hidden]) {
    flex-direction: column;
  }

  .game-nav {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .game-nav .btn {
    width: auto;
  }
}

.locale-select-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.locale-select-label--auth {
  margin-bottom: 0.75rem;
}

.login-card .locale-select-label {
  margin-bottom: 14px;
}

.locale-select {
  width: 100%;
  max-width: 14rem;
  padding: 6px 32px 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background-color: var(--panel-2);
  color: var(--text);
  color-scheme: dark;
}

.locale-select option {
  background-color: var(--panel);
  color: var(--text);
}
