* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #111827;
  background:
    linear-gradient(45deg, #e7eef3 25%, transparent 25%) -20px 0/40px 40px,
    linear-gradient(-45deg, #e7eef3 25%, transparent 25%) -20px 0/40px 40px,
    linear-gradient(45deg, transparent 75%, #e7eef3 75%) -20px 0/40px 40px,
    linear-gradient(-45deg, transparent 75%, #e7eef3 75%) -20px 0/40px 40px,
    #edf3f7;
}
.layout {
  --sidebar-width: 360px;
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 200ms ease;
}
.sidebar { background: #1f2937; color: #e5e7eb; padding: 12px; overflow: auto; }
.sidebar-toggle {
  position: fixed;
  left: calc(var(--sidebar-width) - 1px);
  top: 50%;
  transform: translate(0, -50%);
  z-index: 29000;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 0 8px 8px 0;
  width: 27px;
  height: 96px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 2px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.35);
}
.sidebar-toggle:hover {
  background: #1e293b;
}
body.sidebar-collapsed .layout {
  --sidebar-width: 0px;
  grid-template-columns: 0 1fr;
}
body.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}
body.sidebar-collapsed .manual-modal {
  left: 0 !important;
}
body.sidebar-collapsed .sidebar-toggle {
  left: 0;
}
.sidebar h1 { margin: 6px 0 12px; font-size: 24px; }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-head h1 {
  margin: 6px 0 12px;
}
.lang-toggle {
  height: 30px;
  min-width: 52px;
  padding: 0 10px;
  border: 1px solid #8aa9bf;
  border-radius: 999px;
  background: #eef5fa;
  color: #0f3554;
  font-size: 12px;
  font-weight: 700;
}
.lang-toggle:hover {
  background: #e2edf5;
}
.card { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 10px; margin-bottom: 12px; display: grid; gap: 8px; }
.board { position: relative; padding: 18px 24px; overflow: auto; background: transparent; }
.board {
  zoom: 1;
}
.topbar { display: flex; gap: 10px; margin-bottom: 10px; }
.pill { background: #f8fafc; border: 1px solid #93b5c9; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.ui-ver { margin-left: auto; color: #334155; font-weight: 700; }
.zoom-controls {
  position: fixed;
  left: 364px;
  top: 12px;
  z-index: 28000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid #93b5c9;
  border-radius: 999px;
  padding: 6px 8px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
}
.sidebar-collapsed .zoom-controls {
  left: 8px;
}
.zoom-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 999px;
  border: 1px solid #8aa9bf;
  background: #eef5fa;
  color: #0f3554;
  font-weight: 700;
  padding: 0;
  line-height: 1;
  font-size: 20px;
}
.zoom-btn:hover {
  background: #e2edf5;
}
.zoom-value {
  min-width: 50px;
  text-align: center;
  color: #0f3554;
  font-size: 16px;
  font-weight: 700;
}
.hint-pill {
  margin-bottom: 10px;
  border-radius: 10px;
  display: block;
  width: fit-content;
  max-width: calc(100% - 8px);
}
.bag-pill {
  margin-bottom: 12px;
  border-radius: 10px;
  display: block;
  width: fit-content;
  max-width: calc(100% - 8px);
  background: #f1f5f9;
}
.bag-pill-label,
.bag-pill-item {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.bag-pill-item {
  gap: 6px;
}
.bag-pill-item + .bag-pill-item {
  margin-left: 10px;
}
.bag-pill-count {
  min-width: 1.4em;
}
.bag-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  flex: 0 0 auto;
}
.bag-color-R { background: #F5333F; }
.bag-color-Y { background: #FFBF3C; }
.bag-color-B { background: #2563eb; }
.bag-color-W { background: #67E8F9; }
.bag-color-K { background: #111827; }
.winrate-pill {
  border-radius: 10px;
  display: block;
  width: fit-content;
  max-width: calc(100% - 8px);
  background: #f8fafc;
}
.smart-hint-pill {
  border-radius: 10px;
  display: block;
  width: fit-content;
  max-width: calc(100% - 8px);
  background: #f8fafc;
}
.topbar,
.hint-pill,
.bag-pill {
  position: relative;
  z-index: 5;
}
input, select, button { height: 34px; border-radius: 8px; border: 1px solid #d1d5db; padding: 0 10px; }
button { cursor: pointer; background: #2563eb; color: #fff; border: none; }
button:hover { opacity: .92; }
.strength-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.side-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.deal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.strength-btn {
  background: #334155;
  color: #e2e8f0;
}
.side-btn {
  background: #334155;
  color: #e2e8f0;
}
.deal-btn {
  background: #334155;
  color: #e2e8f0;
}
.strength-btn.active {
  background: #0ea5e9;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35);
}
.side-btn.active {
  background: #0ea5e9;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35);
}
.deal-btn.active {
  background: #0ea5e9;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35);
}
.side-btn.locked {
  opacity: 0.6;
}
.deal-btn.locked {
  opacity: 0.6;
}
.control-action {
  margin-top: 6px;
}
.import-progress {
  margin-top: 8px;
  border: 1px solid #c6d7e3;
  border-radius: 8px;
  padding: 8px;
  background: rgba(15, 23, 42, 0.04);
}
.import-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  margin-bottom: 6px;
}
#import-bga-label,
#import-bga-pct {
  color: #ffffff;
  background: #0f3554;
  border: 1px solid #1f4f75;
  border-radius: 999px;
  padding: 2px 10px;
  text-shadow: none;
}
#import-bga-pct {
  min-width: 56px;
  text-align: center;
}
.import-progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #c8d8e6;
  overflow: hidden;
  border: 1px solid #adc3d5;
}
.import-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  transition: width 180ms ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.account-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.account-title-row h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.achievement-trigger {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #8aa9bf;
  border-radius: 999px;
  background: #eef5fa;
  color: #0f3554;
  font-size: 12px;
  font-weight: 700;
  line-height: 28px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.achievement-trigger:hover {
  background: #e2edf5;
}
.auth-actions button {
  width: 100%;
}
#btn-start.control-action {
  margin-top: 14px;
}
.muted { color: #94a3b8; font-size: 12px; }
#account-remaining {
  font-size: 15px;
  font-weight: 700;
  color: #dbeafe;
  line-height: 1.5;
}
.ops-log {
  margin-top: 8px;
  height: 140px;
  overflow: auto;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid #c6d7e3;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.ops-log-line {
  margin-bottom: 4px;
  color: #334155;
  word-break: break-word;
}
.ops-log-line.warn {
  color: #b45309;
}
.ops-log-line.error {
  color: #b91c1c;
}
.analysis-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.analysis-controls button {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #8aa9bf;
  background: #eef5fa;
  color: #0f3554;
  cursor: pointer;
  font-size: 13px;
}
.analysis-controls button:hover {
  background: #e2edf5;
}
.analysis-panel {
  margin-top: 4px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid #93b5c9;
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 8px;
}
#analysis-panel[hidden] {
  display: none !important;
}
.analysis-panel .muted {
  color: #334155;
  font-size: 13px;
}
.analysis-title {
  font-weight: 700;
  color: #0f3554;
  font-size: 14px;
}
.analysis-list {
  max-height: 92px;
  overflow: auto;
  display: grid;
  gap: 6px;
}
.analysis-item {
  border: 1px solid #b7cad8;
  border-radius: 8px;
  padding: 6px 8px;
  background: #f8fbff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
  color: #0f172a;
}
.analysis-item.current {
  border-color: #38bdf8;
  background: rgba(56,189,248,.14);
}
.analysis-item.blunder {
  border-color: #f59e9e;
  background: rgba(239,68,68,.10);
}
.analysis-item.warn {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.18);
}
.analysis-step-card {
  border: 2px solid rgba(56,189,248,.65);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 40px;
  display: block;
  background: rgba(56,189,248,.12);
  color: #0f172a;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-line;
}
.legal-links {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.legal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #8aa9bf;
  border-radius: 8px;
  background: #eef5fa;
  color: #0f3554;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  box-sizing: border-box;
}
.legal-btn:hover {
  background: #e2edf5;
}
.legal-btn:active {
  transform: translateY(1px);
}
.site-beian {
  margin: 8px 0 14px;
  text-align: center;
  font-size: 12px;
}
.site-beian a {
  color: #475569;
  text-decoration: none;
}
.site-beian a:hover {
  text-decoration: underline;
}
.table-area {
  position: relative;
  min-height: 560px;
  max-width: 980px;
  margin: 8px auto 0;
  background: rgba(255,255,255,0.2);
  border: 1px solid #c6d7e3;
  border-radius: 12px;
  padding: 44px 14px 14px;
}
.factories {
  position: absolute;
  left: 16px;
  top: 64px;
  width: 560px;
  height: 440px;
}
.factory {
  position: absolute;
  width: 156px;
  height: 156px;
  border-radius: 999px;
  border: 3px solid #334155;
  background: radial-gradient(circle at 50% 50%, #d9ecf7 0 35%, #78b7d6 36% 68%, #f8fbfd 69% 100%);
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.factory-title {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #334155;
  font-weight: 700;
  background: #eef5fa;
  border: 1px solid #9db9cc;
  border-radius: 999px;
  padding: 1px 8px;
}
.tile-row {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 8px;
  justify-content: center;
}
.tile-btn, .tile { width: 34px; height: 34px; border-radius: 4px; border: 1px solid #11182722; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.tile-btn { cursor: pointer; }
.tile-selected { box-shadow: 0 0 0 3px #0ea5e9; }
.tile-empty { opacity: .25; border-style: dashed; }

.center-pool {
  position: absolute;
  left: 244px;
  top: 192px;
  width: 104px;
  min-height: 144px;
  border: 2px dashed #8aa9bf;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, 34px);
  grid-template-rows: repeat(3, 34px);
  justify-content: center;
  align-content: center;
  justify-items: center;
  align-items: center;
  gap: 15px;
  background: rgba(255,255,255,.45);
}
.center-stack {
  position: relative;
  width: 34px;
  height: 34px;
}
.center-count {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 22px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #f8fafc;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 0 0 2px #f8fafc;
}
.center-info {
  position: absolute;
  left: 600px;
  top: 12px;
  width: 372px;
  display: grid;
  gap: 8px;
  z-index: 6;
}
.center-info .topbar {
  margin: 0;
  display: block;
}
.center-info .pill,
.center-info .hint-pill,
.center-info .bag-pill,
.center-info .smart-hint-pill {
  width: 100%;
  max-width: 100%;
  margin: 0;
  border-radius: 10px;
}
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.players { max-width: 980px; margin-left: auto; margin-right: auto; }
.player-card {
  background: linear-gradient(180deg, #f8f2e8 0, #f1e8da 100%);
  border: 2px solid #8aa9bf;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.player-card h3 { margin: 4px 0 10px; }
.board-grid { display: grid; grid-template-columns: auto auto; gap: 14px; justify-content: center; }
.pattern-panel { display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start; }
.wall-panel { display: flex; flex-direction: column; align-items: flex-start; }
.row-line { display: flex; gap: 8px; align-items: center; justify-content: flex-end; min-height: 34px; margin-bottom: 8px; }
.op-tiles { display: flex; gap: 8px; justify-content: flex-end; min-width: 220px; }
.op-tiles-pattern {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  gap: 8px;
  min-width: 202px;
}
.tile-spacer {
  opacity: 0;
  border: none !important;
  background: transparent !important;
}
.floor-main {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  gap: 8px;
  min-width: 202px;
  max-width: 202px;
}
.floor-tail {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 8px;
  min-width: 76px;
  max-width: 76px;
}
.floor-row {
  position: relative;
  width: 202px;
  min-width: 202px;
}
.floor-row .floor-main {
  width: 202px;
  min-width: 202px;
}
.floor-row .floor-tail {
  position: absolute;
  left: 210px;
  top: 0;
}
.row-tag {
  width: 24px;
  text-align: center;
  font-size: 12px;
  color: #475569;
  font-weight: 700;
}
.target-slot { cursor: pointer; border-radius: 8px; }
.target-slot.slot-disabled { cursor: default; }
.target-slot:not(.slot-disabled):hover { background: rgba(14, 165, 233, 0.08); }
.wall-cell { width: 34px; height: 34px; border: 1px solid #94a3b8; border-radius: 4px; }
.tile-empty { opacity: .9; background: #e5e7eb !important; border: 1px dashed #94a3b8; }
.is-you { color: #0369a1; }
.floor-slot {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.floor-base {
  position: absolute;
  inset: 0;
}
.floor-tile {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.floor-slot .pen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #0f172a;
  font-weight: 700;
  z-index: 3;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.floor-slot .pen.pen-badge {
  align-items: center !important;
  justify-content: center !important;
  padding-bottom: 0;
  font-size: 17px !important;
  font-weight: 800;
  letter-spacing: 0;
}
.anim-tile {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid #11182755;
  z-index: 9999;
  pointer-events: none;
  transition: transform 560ms ease-in-out, opacity 560ms ease-in-out;
}
.anim-source-hidden {
  visibility: visible !important;
  color: transparent !important;
  background: #e5e7eb !important;
  background-image: none !important;
  border: 1px dashed #94a3b8 !important;
  box-shadow: none !important;
  cursor: default !important;
  pointer-events: none !important;
}
.anim-source-hidden-center {
  visibility: visible !important;
  color: transparent !important;
  background: #e5e7eb !important;
  background-image: none !important;
  border: 1px dashed #94a3b8 !important;
  box-shadow: none !important;
}
.anim-center-token-hidden {
  visibility: hidden !important;
}
.anim-target-hidden {
  visibility: visible !important;
  color: transparent !important;
  background: #e5e7eb !important;
  background-image: none !important;
  border: 1px dashed #94a3b8 !important;
  box-shadow: none !important;
}
.anim-center-target-hidden {
  visibility: hidden !important;
}
.anim-center-target-dashed .tile,
.anim-center-target-dashed .tile-btn,
.anim-center-target-dashed .src-tile {
  visibility: visible !important;
  color: transparent !important;
  background: #e5e7eb !important;
  background-image: none !important;
  border: 1px dashed #94a3b8 !important;
  box-shadow: none !important;
}
.anim-center-target-dashed .center-count {
  visibility: hidden !important;
}
.score-pop {
  position: absolute;
  z-index: 10000;
  font-size: 18px;
  font-weight: 800;
  color: #0ea5e9;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95);
  opacity: 0;
  transform: translateY(6px) scale(0.9);
  transition: transform 260ms ease-out, opacity 260ms ease-out;
  pointer-events: none;
}
.score-pop.show {
  opacity: 1;
  transform: translateY(-10px) scale(1);
}
.score-pop-neg {
  color: #ef4444;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35), 0 0 2px rgba(255, 255, 255, 0.95);
}
.final-bonus-pop {
  color: #f59e0b;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35), 0 0 2px rgba(255, 255, 255, 0.95);
}
.final-bonus-highlight {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.9), 0 0 14px rgba(251, 191, 36, 0.5);
  transform: scale(1.04);
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.winner-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30000;
}
.winner-modal.show {
  display: flex;
}
.achievement-unlock-modal {
  z-index: 32000;
}
.achievement-unlock-dialog {
  min-width: 340px;
  max-width: 480px;
}
.winner-dialog {
  min-width: 320px;
  max-width: 460px;
  background: #fff;
  border: 2px solid #8aa9bf;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
}
.winner-dialog h3 {
  margin: 0 0 8px;
  color: #0f172a;
}
.winner-dialog p {
  margin: 0 0 14px;
  color: #1f2937;
}
#winner-text {
  white-space: pre-line;
}
.winner-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.achievement-dialog {
  min-width: 360px;
  max-width: 560px;
  min-height: 420px;
}
.achievement-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.achievement-item {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
}
.achievement-item.unlocked {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}
.achievement-item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  color: #0f172a;
}
.achievement-item-desc {
  color: #334155;
  font-size: 13px;
  line-height: 1.45;
}
.achievement-item-status {
  color: #0f3554;
  font-size: 12px;
  font-weight: 700;
}
.achievement-item button {
  justify-self: flex-end;
  height: 30px;
  padding: 0 12px;
}
.upgrade-dialog {
  width: min(1080px, calc(100vw - 60px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  border: 2px solid #8aa9bf;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 14px;
}
.replay-credit-dialog {
  width: min(760px, calc(100vw - 60px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  border: 2px solid #8aa9bf;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 14px;
}
.replay-credit-card {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.replay-credit-intro {
  color: #334155;
  line-height: 1.6;
}
.replay-credit-price {
  font-size: 30px;
  color: #f59e0b;
  font-weight: 700;
}
.upgrade-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.upgrade-head h3 {
  margin: 0;
  color: #0f172a;
}
.upgrade-head button {
  background: #334155;
}
.upgrade-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.plan-card {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px;
  min-height: 308px;
  display: grid;
  grid-template-rows: auto 34px auto 1fr;
  gap: 6px;
}
.plan-card.active {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}
.plan-card h4 {
  margin: 0;
  font-size: 28px;
  color: #334155;
}
.plan-sub {
  margin: 0;
  color: #64748b;
  line-height: 1.35;
}
.plan-price {
  font-size: 30px;
  color: #f59e0b;
  font-weight: 700;
  margin-top: -6px;
}
.plan-features {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #334155;
  display: grid;
  gap: 4px;
}
.upgrade-redeem {
  display: flex;
  gap: 10px;
  align-items: center;
}
.upgrade-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #334155;
  font-weight: 600;
}
.upgrade-pay-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.upgrade-pay-actions select {
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: #0f172a;
  font-weight: 600;
}
.upgrade-cta button {
  background: #334155;
  width: 150px;
}
.upgrade-redeem input {
  flex: 1;
}
.upgrade-redeem button {
  width: 160px;
}
#upgrade-modal.guest-view #upgrade-redeem {
  display: none !important;
}
#replay-credit-modal.guest-view #replay-credit-redeem {
  display: none !important;
}
.upgrade-policy {
  margin-top: -4px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(14, 165, 233, 0.08);
  color: #0f172a;
}
.manual-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 360px;
  background: rgba(2, 6, 23, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 31000;
}
.manual-modal.show {
  display: flex;
}
.manual-dialog {
  min-width: 520px;
  max-width: 700px;
  background: #fff;
  border: 2px solid #8aa9bf;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  display: grid;
  gap: 10px;
}
.manual-dialog h3 {
  margin: 0;
  color: #0f172a;
}
.manual-color-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}
.manual-color-main {
  display: flex;
  align-items: center;
  gap: 2px;
}
.manual-missing-wrap {
  margin-left: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.manual-missing-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.manual-color-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #33415555;
  color: transparent;
  flex: 0 0 auto;
}
.manual-color-btn:disabled {
  opacity: 0.5;
}
.manual-missing-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #33415555;
  color: #0f172a;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.85);
  flex: 0 0 auto;
}
.manual-missing-btn:disabled {
  opacity: 0.5;
}
.manual-factory-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.manual-factory-box {
  border: 1px solid #93b5c9;
  border-radius: 10px;
  padding: 8px;
  background: #f8fafc;
  min-height: 122px;
}
.manual-factory-box.next-target {
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.45);
}
.manual-factory-title {
  font-size: 12px;
  color: #334155;
  font-weight: 700;
  margin-bottom: 6px;
}
.manual-tiles {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 6px;
  justify-content: center;
}
.manual-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.auth-modal-actions {
  justify-content: center;
  margin-top: 10px;
}
.winner-modal#auth-modal .winner-dialog {
  min-width: 400px;
  max-width: 560px;
  padding: 24px 26px;
}
.winner-modal#auth-modal #auth-modal-title {
  font-size: 24px;
  margin-bottom: 12px;
}
.winner-modal#auth-modal input {
  height: 42px;
  font-size: 16px;
  padding: 0 12px;
  border-radius: 10px;
}
.winner-modal#auth-modal #auth-modal-msg {
  font-size: 14px;
}
.winner-modal#auth-modal .auth-modal-actions {
  gap: 12px;
}
.winner-modal#auth-modal .auth-modal-actions button {
  height: 42px;
  min-width: 112px;
  font-size: 16px;
}
.auth-agreement {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 2px;
  color: #334155;
  font-size: 14px;
  line-height: 1.5;
}
.auth-agreement input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.auth-agreement a {
  color: #0369a1;
  text-decoration: none;
}
.auth-agreement a:hover {
  text-decoration: underline;
}
.tile-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
.json { background: #0b1220; color: #cbd5e1; border-radius: 8px; padding: 8px; }
.small { max-height: 130px; overflow: auto; }

@media (max-width: 1400px) {
  .layout {
    --sidebar-width: 320px;
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  .players { grid-template-columns: 1fr; }
  .manual-modal { left: 280px; }
  .upgrade-plans { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .layout {
    --sidebar-width: 250px;
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  .zoom-controls {
    left: 8px;
    top: auto;
    bottom: 20px;
    padding: 4px 6px;
    gap: 6px;
    z-index: 22000;
  }
  .zoom-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 18px;
  }
  .zoom-value {
    min-width: 42px;
    font-size: 14px;
  }
  .sidebar-toggle {
    left: calc(var(--sidebar-width) - 1px);
    top: auto;
    bottom: 148px;
    transform: none;
    width: 22px;
    height: 64px;
    font-size: 12px;
    letter-spacing: 1px;
    z-index: 21000;
  }
  body.sidebar-collapsed .sidebar-toggle {
    left: 0;
  }
}
