.games-page {
  --games-owned: #6677a8;
  --games-owned-soft: color-mix(in srgb, var(--games-owned) 10%, var(--panel));
  --games-xp: #8975a8;
  --games-xp-soft: color-mix(in srgb, var(--games-xp) 10%, var(--panel));
}

.games-page-head {
  align-items: flex-end;
  margin-bottom: 14px;
}

.games-project-fields {
  display: flex;
  gap: 8px;
}

.games-project-fields label,
.games-modal > label,
.games-form-row label {
  display: grid;
  gap: 5px;
}

.games-project-fields label > span,
.games-modal label > span,
.games-size-field > span {
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.games-project-fields input {
  width: 146px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
}

.games-view-switch {
  display: flex;
  gap: 22px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.games-view-switch button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 39px;
  padding: 0 1px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.games-view-switch button::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
}

.games-view-switch button.is-active { color: var(--ink); }
.games-view-switch button.is-active::after { background: var(--ink); }
.games-view-switch svg { width: 14px; height: 14px; }

.games-workspace-view {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.games-workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}

.games-workspace-toolbar > div:first-child {
  display: grid;
  gap: 2px;
}

.games-workspace-toolbar strong {
  color: var(--ink);
  font-size: 0.79rem;
}

.games-workspace-toolbar span {
  color: var(--muted);
  font-size: 0.65rem;
}

.games-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.games-toolbar-actions .btn {
  min-height: 36px;
  border-radius: 8px;
}

.games-ready-count {
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}

.games-zoom-controls {
  display: flex;
  align-items: center;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.games-zoom-controls button {
  display: grid;
  height: 100%;
  min-width: 32px;
  place-items: center;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.64rem;
  font-weight: 700;
  cursor: pointer;
}

.games-zoom-controls button:last-child { border-right: 0; border-left: 1px solid var(--line); }
.games-zoom-controls button:hover { background: var(--panel-2); color: var(--ink); }
.games-zoom-controls button svg { width: 12px; height: 12px; }
.games-zoom-controls output { min-width: 44px; color: var(--muted); font-size: 0.62rem; text-align: center; font-variant-numeric: tabular-nums; }

.games-flow-board {
  position: relative;
  height: 680px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background-color: var(--panel);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--muted) 22%, transparent) 1px, transparent 1px);
  background-position: var(--games-grid-x, 0) var(--games-grid-y, 0);
  background-size: var(--games-grid-size, 22px) var(--games-grid-size, 22px);
}

.games-flow-board.is-panning { cursor: grabbing; }

.games-flow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--games-world-width);
  height: var(--games-world-height);
  transform-origin: 0 0;
  will-change: transform;
}

.games-flow-label {
  position: absolute;
  z-index: 4;
  top: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.games-flow-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.games-flow-label-owned { top: 1580px; left: 2320px; color: var(--games-owned); }
.games-flow-label-xp { top: 1580px; left: 3480px; color: var(--games-xp); }
.games-flow-svg { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.games-channel-bubble {
  position: absolute;
  z-index: 3;
  display: grid;
  width: var(--games-size);
  height: var(--games-size);
  place-content: center;
  justify-items: center;
  gap: 3px;
  padding: 11px;
  transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, currentColor 32%, var(--line));
  border-radius: 50%;
  color: var(--games-owned);
  background: var(--games-owned-soft);
  text-align: center;
  cursor: grab;
  user-select: none;
  transition: box-shadow 120ms ease, border-color 120ms ease;
}

.games-channel-xp {
  color: var(--games-xp);
  background: var(--games-xp-soft);
}

.games-channel-bubble:hover,
.games-channel-bubble:focus-visible,
.games-channel-bubble.is-moving,
.games-channel-bubble.is-resizing {
  z-index: 6;
  border-color: currentColor;
  outline: none;
  box-shadow: 0 5px 18px color-mix(in srgb, currentColor 15%, transparent);
}

.games-channel-bubble.is-moving { cursor: grabbing; }
.games-channel-bubble > svg { width: 17px; height: 17px; pointer-events: none; }
.games-channel-bubble > strong { max-width: 104px; color: var(--ink); font-size: 0.63rem; line-height: 1.15; pointer-events: none; }
.games-channel-bubble > small { max-width: 96px; color: var(--muted); font-size: 0.52rem; line-height: 1.15; pointer-events: none; }

.games-channel-ready {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}

.games-channel-ready svg { width: 10px; height: 10px; }

.games-resize-handle {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--panel);
  color: inherit;
  opacity: 0;
  cursor: nwse-resize;
  transition: opacity 120ms ease;
}

.games-channel-bubble:hover .games-resize-handle,
.games-channel-bubble:focus-within .games-resize-handle,
.games-channel-bubble.is-resizing .games-resize-handle { opacity: 1; }
.games-resize-handle svg { width: 11px; height: 11px; pointer-events: none; }

.games-flow-destination {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 52%;
  display: grid;
  width: 190px;
  height: 190px;
  place-content: center;
  justify-items: center;
  gap: 7px;
  padding: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--ink);
  color: var(--panel);
  text-align: center;
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--panel) 82%, transparent);
}

.games-flow-destination span {
  color: color-mix(in srgb, var(--panel) 62%, transparent);
  font-size: 0.55rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.games-flow-destination strong {
  max-width: 155px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.45rem;
  line-height: 1;
}

.games-flow-destination small {
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--panel) 22%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--panel) 72%, transparent);
  font-size: 0.56rem;
}

.is-workspace-fullscreen {
  position: fixed;
  z-index: 110;
  inset: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: var(--panel);
}

.is-workspace-fullscreen .games-workspace-toolbar { flex: 0 0 auto; min-height: 66px; padding-inline: 20px; }
.is-workspace-fullscreen .games-flow-board { flex: 1; height: auto; }
.games-fullscreen-open { overflow: hidden; }

.games-calendar-scroll { overflow-x: auto; }
.games-calendar-grid { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); min-width: 920px; }
.games-week { min-width: 0; min-height: 560px; background: var(--panel); }
.games-week + .games-week { border-left: 1px solid var(--line); }
.games-week.is-drop-target { background: color-mix(in srgb, var(--blue) 5%, var(--panel)); }

.games-week > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 64px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-2) 65%, var(--panel));
}

.games-week.is-launch-week > header { box-shadow: inset 0 2px 0 var(--ink); }
.games-week > header > div { display: grid; gap: 3px; }
.games-week > header span { color: var(--ink); font-size: 0.74rem; font-weight: 750; }
.games-week > header strong { overflow: hidden; color: var(--muted); font-size: 0.59rem; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.games-week > header em { color: var(--muted); font-size: 0.59rem; font-style: normal; font-variant-numeric: tabular-nums; }
.games-week > header button { display: grid; width: 26px; height: 26px; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--muted); cursor: pointer; }
.games-week > header button:hover { color: var(--ink); }
.games-week > header button svg { width: 13px; height: 13px; }

.games-event-list { display: grid; align-content: start; padding: 0 12px; }
.games-event { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) 22px; gap: 8px; align-items: start; padding: 13px 0; border-bottom: 1px solid var(--line); cursor: grab; }
.games-event.is-dragging { opacity: 0.35; }
.games-event.is-done { opacity: 0.5; }
.games-event.is-done strong { text-decoration: line-through; }
.games-event > label { padding-top: 2px; }
.games-event > label input { position: absolute; opacity: 0; }
.games-event > label span { display: grid; width: 16px; height: 16px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--panel); cursor: pointer; }
.games-event > label input:checked + span { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 4px var(--panel); }
.games-event > div { display: grid; gap: 3px; }
.games-event small { color: var(--muted); font-size: 0.57rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.games-event strong { color: var(--ink); font-size: 0.68rem; font-weight: 650; line-height: 1.35; }
.games-event em { color: var(--games-owned); font-size: 0.57rem; font-style: normal; }
.games-event-xp em { color: var(--games-xp); }
.games-event > button { display: grid; width: 22px; height: 22px; place-items: center; border: 0; background: transparent; color: var(--muted); opacity: 0; cursor: pointer; }
.games-event:hover > button { opacity: 1; }
.games-event > button svg { width: 12px; height: 12px; }
.is-workspace-fullscreen .games-calendar-scroll { flex: 1; display: flex; overflow: auto; }
.is-workspace-fullscreen .games-calendar-grid { flex: 1; min-width: 1000px; }
.is-workspace-fullscreen .games-week { min-height: calc(100vh - 66px); }

.games-modal-backdrop {
  position: fixed;
  z-index: 130;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 16, 0.52);
}

.games-modal {
  display: grid;
  gap: 15px;
  width: min(430px, 100%);
  max-height: calc(100vh - 36px);
  padding: 20px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
}

.games-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.games-modal-head span { color: var(--muted); font-size: 0.61rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.games-modal-head h2 { margin: 3px 0 0; color: var(--ink); font-size: 1.15rem; }
.games-modal-head > button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--muted); cursor: pointer; }
.games-modal-head > button svg { width: 14px; }

.games-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.games-modal input:not([type="checkbox"]):not([type="range"]),
.games-modal select { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--ink); font: inherit; font-size: 0.74rem; }
.games-size-field > span { display: flex; justify-content: space-between; }
.games-size-field output { color: var(--ink); }
.games-size-field input { width: 100%; accent-color: var(--ink); }

.games-ready-toggle { grid-template-columns: 1fr auto; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.games-ready-toggle > span { display: grid; gap: 2px; letter-spacing: normal; text-transform: none; }
.games-ready-toggle strong { color: var(--ink); font-size: 0.72rem; }
.games-ready-toggle small { color: var(--muted); font-size: 0.62rem; font-weight: 500; }
.games-ready-toggle input { width: 18px; height: 18px; accent-color: var(--ink); }
.games-modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }
.games-modal-actions .btn { min-width: 104px; min-height: 40px; }
.games-delete-btn { margin-right: auto; color: var(--red); }

@media (max-width: 900px) {
  .games-page-head { align-items: flex-start; flex-direction: column; }
  .games-project-fields { width: 100%; }
  .games-project-fields label { flex: 1; }
  .games-project-fields input { width: 100%; }
}

@media (max-width: 760px) {
  .games-workspace-toolbar { align-items: flex-start; flex-direction: column; padding: 12px; }
  .games-toolbar-actions { width: 100%; flex-wrap: wrap; }
  .games-ready-count { margin-right: auto; }
  .games-zoom-controls { display: none; }
  .games-flow-board { display: block; height: auto; padding: 0; touch-action: auto; cursor: default; }
  .games-flow-canvas { position: relative; display: grid; width: auto; height: auto; gap: 7px; padding: 52px 10px 10px; transform: none !important; }
  .games-flow-svg { display: none; }
  .games-flow-label { top: 18px; }
  .games-flow-label-owned { left: 13px; }
  .games-flow-label-xp { right: 13px; left: auto; }
  .games-flow-destination,
  .games-channel-bubble { position: relative; inset: auto; transform: none; }
  .games-flow-destination { grid-row: 1; width: 100%; height: 120px; border-radius: 9px; box-shadow: none; }
  .games-channel-bubble { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; width: 100%; height: auto; min-height: 62px; justify-items: start; align-items: center; border-radius: 9px; text-align: left; cursor: pointer; }
  .games-channel-bubble > strong { max-width: none; font-size: 0.7rem; }
  .games-channel-bubble > small { max-width: none; font-size: 0.59rem; }
  .games-channel-ready { position: static; }
  .games-resize-handle { display: none; }
  .games-calendar-grid { grid-template-columns: 1fr; min-width: 0; }
  .games-week { min-height: 180px; }
  .games-week + .games-week { border-top: 1px solid var(--line); border-left: 0; }
  .is-workspace-fullscreen .games-calendar-grid { min-width: 0; }
  .is-workspace-fullscreen .games-week { min-height: 180px; }
}

@media (max-width: 520px) {
  .games-project-fields,
  .games-form-row { grid-template-columns: 1fr; flex-direction: column; }
  .games-project-fields label { width: 100%; }
  .games-view-switch { gap: 18px; }
  .games-toolbar-actions .btn { flex: 1; }
}

@media print {
  .topbar,
  .sidebar,
  .games-page-head,
  .games-view-switch,
  .games-workspace-toolbar { display: none !important; }
  .games-workspace-view { border: 0; }
  .games-calendar-grid { min-width: 0; }
}
