* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #f5f1e8 0%, #e8edf5 100%);
  color: #1f2933;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select {
  border-radius: 2px;
  border: 1px solid #bcccdc;
  padding: 10px 12px;
}

button {
  background: #174a7e;
  border-color: #174a7e;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

button:hover {
  background: #12395f;
}

input[type="range"] {
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}

.app-container {
  height: 100vh;
  padding: 16px;
}

.app-frame {
  position: relative;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100%;
  gap: 14px;
}

.page-stack {
  min-width: 0;
  min-height: 0;
}

.sidebar-nav {
  position: relative;
  z-index: 1600;
  width: 240px;
  padding: 0;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 14px rgba(31, 41, 51, 0.04);
  overflow: visible;
}

.sidebar-nav-inner,
.sidebar-nav {
  min-height: 0;
}

.sidebar-nav {
  height: 100%;
}

.sidebar-nav-header,
.sidebar-links {
  display: flex;
  flex-direction: column;
}

.sidebar-nav-header {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 3px double rgba(31, 41, 51, 0.18);
}

.sidebar-toggle,
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 9px 12px;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: #1f2933;
  position: relative;
}

.sidebar-links {
  gap: 0;
  border-top: 0;
}

.sidebar-nav-header,
.sidebar-link {
  position: relative;
}

.sidebar-link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: rgba(31, 41, 51, 0.09);
}

.sidebar-links > .sidebar-link:last-child::after,
.sidebar-subnav .sidebar-link:last-child::after {
  display: none;
}

.sidebar-toggle.active,
.sidebar-toggle:hover,
.sidebar-link.active,
.sidebar-link:hover {
  background: #eef2f6;
  color: #174a7e;
}

.sidebar-toggle {
  height: 56px;
}

.sidebar-group {
  position: relative;
}

.sidebar-group::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: rgba(31, 41, 51, 0.09);
}

.sidebar-group-heading {
  font-weight: 800;
  cursor: default;
}

.sidebar-group-heading::after {
  display: none;
}

.sidebar-subnav {
  padding: 0 0 6px 0;
}

.sidebar-subnav-link {
  min-height: 46px;
  padding-left: 32px;
  color: #52616f;
}

.sidebar-subnav-link .nav-icon {
  width: 28px;
  height: 28px;
}

.sidebar-subnav-link .nav-icon svg {
  width: 21px;
  height: 21px;
}

.nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #174a7e;
  color: #ffffff;
  stroke: currentColor;
  font-weight: 800;
  flex: 0 0 auto;
}

.nav-icon svg {
  width: 24px;
  height: 24px;
  display: block;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vector-effect: non-scaling-stroke;
}

.sidebar-link .nav-icon {
  background: #e7edf4;
  color: #7b8794;
}

.sidebar-toggle.active .nav-icon,
.sidebar-toggle:hover .nav-icon,
.sidebar-link.active .nav-icon,
.sidebar-link:hover .nav-icon {
  background: #174a7e;
  color: #ffffff;
}

.nav-label {
  position: static;
  transform: none;
  padding: 0;
  background: transparent;
  color: currentColor;
  white-space: normal;
  opacity: 1;
  max-width: 150px;
  pointer-events: auto;
  box-shadow: none;
  transition: none;
  font-weight: 700;
  z-index: auto;
}

.page-view {
  display: none;
  height: 100%;
  min-height: 0;
}

.page-view.active {
  display: block;
}

.page-view-scrollable {
  overflow: auto;
  padding-right: 6px;
}

.simulation-layout,
.creator-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  gap: 14px;
}

.simulation-layout {
  grid-template-columns: minmax(0, 1.5fr) 360px;
}

.creator-layout {
  grid-template-columns: minmax(0, 1.55fr) 360px;
}

.sim-panel,
.card,
.howto-card,
.creator-stage-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(31, 41, 51, 0.06);
  border-radius: 0;
  box-shadow: 0 4px 14px rgba(31, 41, 51, 0.04);
}

.sim-panel,
.creator-stage-card {
  padding: 16px;
}

.sim-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.creator-stage-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.panel-header,
.section-title-row,
.button-row,
.type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-header h1,
.card h2,
.section-title-row h3,
.creator-stage-card h1,
.howto-card h1,
.howto-card h2 {
  margin: 0;
}

.panel-header p,
.howto-card p {
  margin: 8px 0 0;
  color: #52606d;
}

.panel-header-compact {
  flex: 0 0 auto;
}

.simulation-surface {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  transition: filter 260ms ease, transform 260ms ease;
}

.sim-panel.results-visible .simulation-surface {
  filter: blur(4px);
  transform: scale(0.992);
}

.canvas-wrap {
  background: #dbe2ea;
  padding: 8px;
  border-radius: 0;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

#grid-canvas {
  width: auto;
  height: 100%;
  max-width: 100%;
  min-height: 0;
  display: block;
  background: #fffdf8;
  border-radius: 0;
  aspect-ratio: 1;
}

.simulation-results-overlay {
  position: absolute;
  inset: 18px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(245, 241, 232, 0.28);
  pointer-events: none;
  opacity: 0;
  display: none;
}

.simulation-results-overlay.active {
  display: flex;
  animation: scoreboardFadeIn 320ms ease forwards;
}

.results-card {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 0;
  box-shadow: 0 18px 40px rgba(31, 41, 51, 0.16);
  padding: 18px 0 0;
  overflow: hidden;
}

.results-card h2 {
  margin: 0;
  padding: 0 22px 14px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.scoreboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.scoreboard-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: stretch;
  column-gap: 12px;
  min-width: 0;
  padding: 12px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.scoreboard-item::before {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 0;
  height: 1px;
  background: rgba(31, 41, 51, 0.08);
}

.scoreboard-item:first-child::before {
  display: none;
}

.scoreboard-rank-rail {
  display: flex;
  align-items: center;
  justify-content: center;
}

.scoreboard-rank {
  display: block;
  width: 100%;
  text-align: center;
  flex: 0 0 auto;
  font-weight: 800;
  color: #174a7e;
}

.scoreboard-main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.scoreboard-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.scoreboard-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.scoreboard-label {
  font-weight: 700;
}

.scoreboard-tie-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border: 1px solid rgba(23, 74, 126, 0.18);
  background: rgba(23, 74, 126, 0.08);
  color: #174a7e;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.scoreboard-meta {
  color: #52606d;
  font-size: 0.92rem;
}

.sim-side-column,
.creator-side-column {
  min-height: 0;
  display: grid;
  gap: 1px;
  padding: 0;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 0;
  background: rgba(31, 41, 51, 0.08);
  overflow: hidden;
}

.sim-side-column {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.creator-side-column {
  grid-template-rows: auto minmax(0, 1fr);
}

.card {
  padding: 14px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.compact-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-card {
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.button-row {
  flex-wrap: wrap;
  margin-top: 6px;
}

.control-cluster {
  justify-content: flex-start;
  gap: 8px;
}

.control-cluster button {
  min-width: 92px;
}

.control-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  color: #52606d;
}

.control-status-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.control-status-value {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2933;
}

.compact-actions {
  margin-top: 0;
  justify-content: flex-start;
  gap: 8px;
}

.btn-danger {
  background: #b42318;
  border-color: #b42318;
}

.btn-danger:hover {
  background: #8f1c13;
}

.btn-play {
  background: #0f7a5c;
  border-color: #0f7a5c;
}

.btn-play:hover {
  background: #0b6048;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.simulation-form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.simulation-speed-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.simulation-speed-label {
  white-space: nowrap;
}

.slider-field {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.slider-field input[type="range"] {
  width: 100%;
  direction: ltr;
}

.slider-field input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #d0dbe7;
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 34px;
  margin-top: -13px;
  border: 1px solid #12395f;
  border-radius: 4px;
  background: #174a7e;
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.18);
}

.slider-field input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #d0dbe7;
}

.slider-field input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 34px;
  border: 1px solid #12395f;
  border-radius: 4px;
  background: #174a7e;
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.18);
}

.picker-option {
  background: #fbfcfe;
  color: #1f2933;
  border-color: #d9e2ec;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
}

.picker-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}

.picker-option-row .picker-option {
  min-width: 0;
}

.picker-option-action {
  min-width: 92px;
  padding: 8px 10px;
  background: transparent;
  border-color: #d9e2ec;
  color: #174a7e;
  font-size: 0.86rem;
  font-weight: 800;
}

.picker-option-action:hover {
  background: #eef2f6;
  border-color: #174a7e;
  color: #12395f;
}

.picker-option-no-swatch {
  grid-template-columns: minmax(0, 1fr);
}

.picker-option-selected {
  background: #eef2f6;
  border-color: #174a7e;
  color: #174a7e;
}

.picker-option-draggable {
  cursor: grab;
}

.picker-option.dragging,
.roster-slot-main.dragging {
  opacity: 0.5;
}

.picker-option:hover {
  background: #f1f5f9;
  border-color: #c8d7ea;
  color: #174a7e;
}

.picker-option-name {
  font-weight: 700;
}

.picker-option-meta {
  color: #52606d;
  font-size: 0.9rem;
  margin-top: 2px;
}

.picker-empty {
  padding: 12px;
  border-radius: 0;
  background: #f7f9fc;
  color: #52606d;
  text-align: center;
}

.roster-slots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 2px;
  min-height: 0;
  height: 100%;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.roster-panel-launcher {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.roster-panel-launcher:hover,
.roster-panel-launcher:focus-visible {
  background: #fbfcfe;
  border-color: rgba(23, 74, 126, 0.24);
  box-shadow: inset 0 0 0 1px rgba(23, 74, 126, 0.16);
  outline: none;
}

.roster-panel-launcher .roster-slot-main,
.roster-panel-launcher .roster-slot-placeholder {
  pointer-events: none;
}

.roster-card {
  overflow: hidden;
}

.roster-panel-launcher:hover .section-title-row,
.roster-panel-launcher:hover .panel-inline-hint,
.roster-panel-launcher:focus-visible .section-title-row,
.roster-panel-launcher:focus-visible .panel-inline-hint {
  color: #174a7e;
}

.panel-inline-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  color: #52606d;
  font-size: 0.82rem;
}

.roster-slot {
  min-height: 0;
  height: 44px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  position: relative;
}

.roster-slot::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  height: 1px;
  background: rgba(31, 41, 51, 0.08);
}

.roster-slot:first-child::before {
  display: none;
}

.drop-target-active {
  background: rgba(23, 74, 126, 0.08);
}

.arena-drop-target-active {
  background: rgba(23, 74, 126, 0.06);
  box-shadow: inset 0 0 0 1px rgba(23, 74, 126, 0.18);
}

.roster-slot-card,
.roster-slot-empty,
.roster-slot-placeholder {
  width: 100%;
  min-height: 0;
  height: 44px;
}

.roster-slot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0;
  align-items: stretch;
  padding: 0;
}

.roster-slot-main {
  display: grid;
  grid-template-columns: 28px 14px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: transparent;
  color: inherit;
  border: 0;
  text-align: left;
  padding: 0 10px;
}

.roster-slot-draggable {
  cursor: grab;
}

.roster-slot-main:hover {
  background: #eef2f6;
  color: inherit;
}

.roster-slot-preview .roster-slot-main:hover {
  background: transparent;
}

.roster-slot-empty {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: transparent;
  border: 0;
  color: #174a7e;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0 10px;
}

.roster-slot-empty:hover {
  background: #eef2f6;
}

.roster-slot-placeholder {
  background: transparent;
}

.type-current {
  font-size: 0.92rem;
  font-weight: 800;
  color: #174a7e;
  text-align: center;
}

.type-swatch {
  width: 14px;
  height: 14px;
  border-radius: 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex: 0 0 auto;
}

.type-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.type-meta {
  color: #52606d;
  font-size: 0.92rem;
}

.remove-type-btn {
  min-width: 32px;
  width: 32px;
  height: 44px;
  padding: 0;
  border-radius: 0;
  border: 0;
  border-left: 1px solid rgba(31, 41, 51, 0.08);
  background: transparent;
  color: #52606d;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  align-self: stretch;
}

.remove-type-btn:hover {
  background: #eef2f6;
  color: #1f2933;
}

.blockly-editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

#blockly-editor {
  flex: 1;
  width: 100%;
  border: 1px solid #d9e2ec;
  border-radius: 0;
  overflow: hidden;
  min-height: 0;
}

.blockly-lock-overlay {
  position: absolute;
  inset: 1px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(247, 249, 252, 0.78);
  border: 1px solid rgba(23, 74, 126, 0.18);
  color: #1f2933;
  text-align: center;
  pointer-events: auto;
}

.blockly-lock-overlay[hidden] {
  display: none;
}

.blockly-lock-overlay > div {
  max-width: 360px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(31, 41, 51, 0.12);
  box-shadow: 0 10px 26px rgba(31, 41, 51, 0.12);
}

.blockly-lock-overlay strong,
.blockly-lock-overlay span {
  display: block;
}

.blockly-lock-overlay strong {
  margin-bottom: 6px;
  color: #174a7e;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.creator-details-grid {
  display: grid;
  gap: 14px;
}

.color-palette {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.color-option {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 0;
  border: 2px solid rgba(31, 41, 51, 0.18);
  background: transparent;
  position: relative;
}

.color-option:hover {
  transform: translateY(-1px);
}

.color-option.active {
  border-color: #1f2933;
  box-shadow: 0 0 0 4px rgba(23, 74, 126, 0.14);
}

.color-option::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 0;
  background: var(--swatch-color);
}

.color-option.active::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  right: -1px;
  top: -1px;
  border-radius: 0;
  border: 2px solid #ffffff;
  background: #1f2933;
  z-index: 1;
}

.creator-warning {
  padding: 10px 12px;
  border-radius: 0;
  border: 1px solid #e7b46a;
  background: #fff4e5;
  color: #8a4b08;
  font-weight: 600;
}

.library-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.library-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(9, 18, 28, 0.34);
}

.library-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 48px));
  max-height: min(640px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(31, 41, 51, 0.06);
  box-shadow: 0 16px 36px rgba(31, 41, 51, 0.14);
}

.arena-roster-modal-dialog {
  width: min(1040px, calc(100vw - 48px));
}

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

.library-modal-header h2 {
  margin: 0;
}

.library-modal-close {
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #52606d;
  border-color: rgba(31, 41, 51, 0.08);
}

.library-modal-close:hover {
  background: #eef2f6;
  color: #1f2933;
}

.library-modal-tabs {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid #d9e2ec;
}

.library-tab {
  background: transparent;
  border-color: rgba(31, 41, 51, 0.08);
  color: #52606d;
  font-weight: 700;
}

.library-tab.active {
  background: #174a7e;
  border-color: #174a7e;
  color: #ffffff;
}

.library-modal-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.library-modal-status {
  padding: 9px 10px;
  border: 1px solid #d9e2ec;
  background: #f7f9fc;
  color: #1f2933;
  font-size: 0.9rem;
  font-weight: 700;
}

.library-modal-status[data-tone="error"] {
  border-color: rgba(159, 64, 64, 0.36);
  background: #fff5f5;
  color: #8a2c2c;
}

.library-modal-status[data-tone="success"] {
  border-color: rgba(46, 125, 50, 0.3);
  background: #f1f8f3;
  color: #2f6b35;
}

.library-modal-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid #d9e2ec;
}

.arena-roster-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  min-height: 0;
  height: 100%;
}

.arena-roster-library-column,
.arena-roster-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.arena-roster-library-column .library-modal-list,
.arena-roster-column .roster-slots-modal {
  flex: 1;
}

.roster-library-list {
  min-height: 320px;
}

.roster-slots-modal {
  border: 1px solid rgba(31, 41, 51, 0.08);
  min-height: 353px;
}

.howto-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

.account-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

.global-arena-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 360px;
  gap: 14px;
}

.global-arena-main {
  min-height: 0;
}

.global-side-column {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(31, 41, 51, 0.08);
  overflow: hidden;
}

.global-side-column[hidden] {
  display: none !important;
}

.global-schedule-callout,
.global-empty-state,
.global-rules-card,
.global-live-panel,
.global-settings-summary,
.global-submit-box,
.global-queue-metrics,
.global-list-row {
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #f7f9fc;
}

.global-schedule-callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
}

.global-schedule-callout strong {
  font-size: 1.1rem;
  color: #174a7e;
}

.eyebrow {
  display: block;
  color: #52606d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.global-empty-state {
  padding: 18px;
  color: #52606d;
}

.global-empty-state h2 {
  margin: 0 0 8px;
  color: #1f2933;
}

.global-empty-state p {
  margin: 8px 0;
}

.global-empty-state-compact {
  padding: 12px;
  font-size: 0.92rem;
}

.global-live-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  min-height: 0;
}

.global-live-panel[hidden] {
  display: none !important;
}

.global-live-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.global-live-header h2 {
  margin: 2px 0 0;
}

.global-live-header strong {
  color: #174a7e;
  white-space: nowrap;
}

.global-replay-canvas {
  width: min(100%, 520px);
  aspect-ratio: 1;
  border: 1px solid rgba(31, 41, 51, 0.16);
  background: #fdfbf7;
}

.global-replay-canvas[hidden],
.global-live-scoreboard[hidden] {
  display: none !important;
}

.global-live-scoreboard {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(31, 41, 51, 0.08);
  border: 1px solid rgba(31, 41, 51, 0.08);
}

.global-scoreboard-row {
  display: grid;
  grid-template-columns: 46px 18px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #f7f9fc;
}

.global-scoreboard-row strong,
.global-scoreboard-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-clickable-row {
  cursor: pointer;
}

.global-clickable-row:hover,
.global-clickable-row:focus {
  outline: 0;
  border-color: rgba(23, 74, 126, 0.38);
  background: #eef2f6;
}

.global-participant-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.global-list-row > .global-participant-list,
.global-list-row > .global-list {
  grid-column: 1 / -1;
  width: 100%;
}

.global-participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #f7f9fc;
}

.global-participant-row-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.global-participant-row-text strong,
.global-participant-row-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-participant-row-text span {
  color: #52606d;
  font-size: 0.86rem;
}

.global-stat-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 7px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  background: #ffffff;
  color: #174a7e;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.global-stat-chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.global-stats-modal-dialog {
  width: min(560px, calc(100vw - 48px));
}

.global-stats-subtitle {
  margin: 4px 0 0;
  color: #52606d;
  font-weight: 700;
}

.global-stats-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.global-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(31, 41, 51, 0.08);
}

.global-stats-item {
  min-width: 0;
  padding: 10px;
  background: #f7f9fc;
}

.global-stats-item span,
.global-stats-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-stats-item span {
  color: #52606d;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.global-stats-item strong {
  margin-top: 3px;
  color: #1f2933;
}

.global-rules-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  min-height: 0;
  overflow: auto;
}

.global-rules-card[hidden] {
  display: none !important;
}

.global-accordion-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
}

.global-accordion-card.active {
  flex: 1 1 auto;
}

.global-accordion-toggle {
  flex: 0 0 auto;
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 0;
  background: #ffffff;
  color: #1f2933;
  font-weight: 800;
}

.global-accordion-toggle:hover {
  background: #eef2f6;
  color: #174a7e;
}

.global-accordion-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  background: #ffffff;
}

.global-accordion-panel[hidden] {
  display: none !important;
}

.global-rule-list {
  margin: 0;
  padding-left: 18px;
  color: #52606d;
  line-height: 1.45;
}

.global-settings-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.global-settings-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #52606d;
}

.global-settings-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.global-settings-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.global-settings-list li:last-child {
  padding-bottom: 0;
}

.global-settings-list strong {
  color: #1f2933;
  text-align: right;
}

.global-queue-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: rgba(31, 41, 51, 0.08);
}

.global-queue-metrics > div {
  padding: 10px;
  background: #f7f9fc;
}

.global-queue-metrics strong {
  display: block;
  margin-top: 2px;
  color: #174a7e;
  font-size: 1.35rem;
}

.global-submit-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
}

.global-submit-box span {
  color: #52606d;
  font-size: 0.92rem;
  font-weight: 700;
}

.global-list-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.global-list-section h3 {
  margin: 0;
  font-size: 0.95rem;
}

.global-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.global-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.global-list-row-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.global-list-row-text strong,
.global-list-row-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-list-row-text span {
  color: #52606d;
  font-size: 0.86rem;
}

.btn-secondary {
  background: transparent;
  border-color: #d9e2ec;
  color: #174a7e;
}

.btn-secondary:hover {
  background: #eef2f6;
  border-color: #174a7e;
  color: #12395f;
}

.placeholder-view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.placeholder-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  text-align: center;
}

.placeholder-card h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.admin-view {
  min-height: 100%;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0;
  overflow: hidden;
  align-self: start;
}

.admin-sidebar .section-title-row {
  padding: 14px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.admin-sidebar-link,
.admin-context-menu button {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  background: #ffffff;
  color: #52606d;
  text-align: left;
  font-weight: 800;
  padding: 12px 14px;
}

.admin-sidebar-link:hover,
.admin-sidebar-link.active,
.admin-context-menu button:hover {
  background: #eef2f6;
  color: #174a7e;
}

#exit-admin-mode-btn {
  margin: 14px;
  width: calc(100% - 28px);
}

.admin-main,
.admin-panel,
.admin-card {
  min-width: 0;
}

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.admin-panel.active {
  display: flex;
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: rgba(31, 41, 51, 0.08);
  border: 1px solid rgba(31, 41, 51, 0.08);
}

.admin-status-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: #f7f9fc;
}

.admin-status-card span,
.admin-list-row span {
  color: #52606d;
  font-size: 0.88rem;
}

.admin-form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: #52606d;
  font-weight: 800;
}

.admin-list-section,
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #f7f9fc;
}

.admin-list-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.admin-list-row-text strong,
.admin-list-row-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-list-row-actions {
  display: flex;
  gap: 8px;
}

.admin-context-menu {
  position: fixed;
  z-index: 5000;
  width: 220px;
  border: 1px solid rgba(31, 41, 51, 0.16);
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 41, 51, 0.16);
}

.admin-context-menu[hidden] {
  display: none !important;
}

.account-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
}

.account-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.account-status-label {
  color: #52606d;
  font-weight: 600;
}

.account-form-grid {
  grid-template-columns: 1fr;
}

#auth-signed-out-section,
#auth-profile-section,
.profile-username-form,
.guest-auth-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#auth-signed-out-section[hidden],
#auth-profile-section[hidden],
#profile-username-display[hidden],
.profile-username-form[hidden],
.guest-auth-panel[hidden] {
  display: none !important;
}

.guest-auth-panel {
  padding-top: 12px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.form-help {
  margin: -6px 0 0;
  color: #52606d;
  font-size: 0.82rem;
  line-height: 1.35;
}

.account-button-row {
  justify-content: flex-start;
}

.auth-status-message {
  padding: 10px 12px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #f7f9fc;
  color: #243b53;
}

.auth-status-message[data-tone="success"] {
  border-color: rgba(0, 158, 115, 0.24);
  background: rgba(0, 158, 115, 0.08);
  color: #0b6e4f;
}

.auth-status-message[data-tone="error"] {
  border-color: rgba(213, 94, 0, 0.24);
  background: rgba(213, 94, 0, 0.08);
  color: #9a3412;
}

.auth-status-message[data-tone="info"] {
  border-color: rgba(23, 74, 126, 0.16);
  background: rgba(23, 74, 126, 0.06);
  color: #174a7e;
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.howto-card {
  padding: 18px;
}

.howto-card p {
  line-height: 1.5;
}

@media (max-width: 1365px) {
  .simulation-layout,
  .creator-layout,
  .global-arena-layout {
    grid-template-columns: 1fr 320px;
  }

  .simulation-form-grid {
    grid-template-columns: 1fr;
  }

  .account-status-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .arena-roster-modal-dialog {
    width: min(760px, calc(100vw - 32px));
  }

  .arena-roster-modal-grid {
    grid-template-columns: 1fr;
  }

  .global-side-column {
    min-height: 420px;
  }
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app-container {
    height: auto;
    min-height: 100vh;
  }

  .app-frame {
    grid-template-columns: 1fr;
  }

  .sidebar-nav {
    display: none;
  }

  .page-stack {
    filter: none !important;
  }

  .simulation-layout,
  .creator-layout,
  .global-arena-layout,
  .admin-view,
  .howto-grid {
    grid-template-columns: 1fr;
  }

  .admin-status-grid,
  .admin-form-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes scoreboardFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
