* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #1a1a2e 0%,#16213e 50%, #0f3460 100%);
  font-family: 'Arial', sans-serif;
  
  min-height: 100%;

  overflow-x: hidden;
  
  background-image: url('/mtg/images/generic-background.png');
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('/mtg/images/generic-background.png');
  background-size: cover;
  background-position: center;
  z-index: 0;
  pointer-events: none;
}

.app-wrapper {
  display: flex;
  flex-direction: column;

  min-height: 100vh;
  height: auto;

  padding: 10px;
  gap: clamp(24px, 5vh, 60px);

  position: relative;
  z-index: 1;

  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.dashboard-intro::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.12),
    rgba(255,255,255,0.02)
  );
}

.dashboard-intro {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;

  max-width: min(92%, 720px);
  padding: 14px 20px;

  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);

  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);

  text-align: center;
  
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}

.dashboard-intro.is-hidden {
  opacity: 0;
  transform: translate(-50%, -10px);
  pointer-events: none;
}

.dashboard-intro h1 {
  margin: 0 0 4px;
  font-family: "Lato", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
}

.dashboard-intro p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.85);
}


.carousel-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 5vh 5vw; /* Universal percentage-based padding */
  overflow: hidden;
}

.app-wrapper,
.player-management,
.management-dropdown,
.carousel-container {
  overflow: visible !important;
}

.mtg-ring-counter .app-container,
.app-container {
  min-width: min(540px, 95vw) !important;
  min-height: min(540px, 95vh) !important;
  max-width: min(95vw, 95vh, 740px) !important;  /* bump cap */
  max-height: min(90vh, 90vw, 740px) !important;
}

.mtg-dashboard-wrapper {
    padding-bottom: 120px;
}

.mtg-page-disclaimer {
  max-width: 1100px;
  margin: 32px auto;
  padding: 14px 16px;

  background: rgba(0, 0, 0, 0.55);
  border-radius: 10px;
  
  height: auto;
  min-height: unset;
  overflow: visible;
}

.mtg-page-disclaimer .disclaimer {
  font-size: 12px;
  color: rgba(255,255,255,0.78);
  text-align: center;
  max-width: 1000px;
  margin: 0 auto;
  line-height: 1.5;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.9),
    0 0 6px rgba(0,0,0,0.6);
}

.mtg-page-disclaimer a[href*="fancontentpolicy"] {
  white-space: nowrap !important;
}

.mtg-legal-toggle {
  margin-top: 6px;
  text-align: center;
  font-size: 11px;
  position: relative;
  padding-bottom: 4px;
}

.mtg-legal-toggle::after {
  content: "";
  display: block;
  width: 40px;
  height: 2px;
  margin: 6px auto 0;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}

.mtg-legal-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mtg-legal-toggle-btn {
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.mtg-legal-toggle-btn:hover {
  color: rgba(255,255,255,0.95);
}

.mtg-legal-toggle-btn:hover,
.mtg-legal-toggle-btn:focus {
  opacity: 1;
}

.mtg-legal-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.3px;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.9),
    0 0 6px rgba(0,0,0,0.6);
}

.mtg-legal-content {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);

  width: min(92vw, 900px);
  max-height: 26vh;
  overflow-y: auto;

  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);

  font-size: 12px;
  color: rgba(255,255,255,0.85);
  text-align: center;
  line-height: 1.45;

  pointer-events: auto;
  animation: legalFadeUp 180ms ease-out;
  
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  z-index: 20;
}

@keyframes legalFadeUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.mtg-legal-content[hidden] {
  display: none;
}

.mtg-legal-content a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mtg-legal-toggle-btn .chevron {
  font-size: 10px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.mtg-legal-toggle-btn:hover .chevron {
  opacity: 0.85;
}

/* Expanded state */
.mtg-legal-toggle-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg); /* ▼ → ▲ */
}

.mtg-legal-content .disclaimer {
  color: rgba(255, 255, 255, 0.85); /* key change */
  font-size: 12px;
  line-height: 1.5;
}

.meta-zone {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-bottom: 4px;
}

.mtg-legal-toggle[aria-expanded="true"]::before {
  content: "";
  display: block;
  width: 80px;
  height: 1px;
  margin: 0 auto 6px;
  background: rgba(255,255,255,0.35);
}

.active-player-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.back-btn {
  opacity: 0.9;
}

.back-btn:hover {
  opacity: 1;
}

.nav-controls {
  position: fixed;
  left: 50%;
  bottom: env(safe-area-inset-bottom);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
  z-index: 1000;
}

[id$="_innerCircle"] {
  position: relative;
}

.inactive-players-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin-bottom: clamp(16px, 2vh, 28px);
}

.inactive-player-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px !important;
  transition: transform 0.2s ease;
  transform-origin: bottom center;
  padding-top: 8px;
  padding-bottom: env(safe-area-inset-bottom);
}

.inactive-player-container:hover {
  transform: translateY(-8px);
  z-index: 100;
}

.inactive-players-row:hover .inactive-player-container {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.inactive-players-row::-webkit-scrollbar {
  height: 6px;
}

.inactive-players-row::-webkit-scrollbar-track {
  background: transparent;
}

.inactive-players-row::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.player-wrapper {
	width: 100%;
	height: 100%;
	position: relative;
	transition: all 0.3s ease;
	bottom: var(--nav-controls-height);
}

.player-wrapper.active {
  position: relative;
  top: clamp(-16px, -3vh, -32px);
  animation: slideInFromBottom 0.5s ease-out;
}

.player-wrapper.active .player-name-label {
	  display: none;
}

.player-wrapper.inactive {
  opacity: 0.7;
  cursor: pointer;
  filter: blur(0.5px);
  position: relative;
}

.player-wrapper.inactive:hover {
  opacity: 0.9;
  filter: blur(0);
}

.player-wrapper.inactive .mtg-ring-counter {
  pointer-events: none;
}

@keyframes slideInFromBottom {
  0% {
	transform: translateY(50vh) scale(0.9);
	opacity: 0;
  }
  100% {
	transform: translateY(0) scale(1);
	opacity: 1;
  }
}

@keyframes slideOutToTop {
  0% {
	transform: translateY(0) scale(1);
	opacity: 1;
  }
  100% {
	transform: translateY(-50vh) scale(0.9);
	opacity: 0;
  }
}

.player-name-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) scale(4);
  transform-origin: center bottom;
  color: white;
  font-size: 16px;
  font-weight: bold;
  white-space: nowrap;
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 1),
    0 0 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
  margin-bottom: 15px;
}

.player-wrapper.inactive .player-name-label {
  bottom: calc(100% + 20px); /* Position 20px above the wrapper */
  margin-bottom: 0;
}

.mtg-ring-counter {
	width: 100% !important;
	height: 100% !important;
	display: flex;
	align-items: center;
	justify-content: center;
}

.app-container {
  width: 100% !important;
  height: 100% !important;
  min-width: min(280px, 80vw) !important;
  min-height: min(280px, 80vh) !important;
  max-width: min(90vw, 90vh, 500px) !important;
  max-height: min(85vh, 85vw) !important; /* Constrain to both dimensions */
  transition: all 0.2s ease;
}

.player-management {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 2000;
  width: 250px !important;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 280px; /* desktop cap */
}

.quick-action-btn {
  flex: 1 1 auto;
  min-width: 60px;
  max-width: 120px; /* desktop cap */
  width: auto !important;  
  padding: 12px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: white;
}

.quick-action-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.9);
}

.quick-action-btn:active {
  transform: translateY(0);
}

.quick-action-btn:focus {
  background: rgba(0, 0, 0, 0.8);
}

.quick-action-icon {
  width:30%;
}

.quick-action-label {
  font-size: 10px;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.quick-action-label::hover {
  color: white;
}

.quick-action-result {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  animation: resultPop 0.6s ease-out;
  pointer-events: none;
  z-index: 10;
}

@keyframes resultPop {
  0% {
	transform: translate(-50%, -50%) scale(0);
	opacity: 0;
  }
  50% {
	transform: translate(-50%, -50%) scale(1.2);
	opacity: 1;
  }
  100% {
	transform: translate(-50%, -50%) scale(1);
	opacity: 1;
  }
}

.dice-rolling {
  animation: diceRoll 0.5s ease-in-out;
}

.coin-flipping {
  animation: coinFlip 0.6s ease-in-out;
}

@keyframes diceRoll {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
  50% { transform: rotate(180deg); }
  75% { transform: rotate(270deg); }
}

@keyframes coinFlip {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(1800deg); }
}

.management-dropdown {
  background: rgba(0, 0, 0, 0.95); 
  backdrop-filter: blur(15px); 
  border-radius: 12px;
  border-bottom: none;
  overflow: visible; /* Allow content to expand beyond */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  width: 250px; /* Fixed width for the container */
  position: relative; /* For positioning the expanded content */
}

.management-dropdown-header {
  padding: 12px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-size: 14px;
  transition: background 0.2s;
  font-weight: 600;
  overflow: visible; /* Allow content to expand beyond */
  border-radius: 12px 12px 0 0;
  border-bottom: none;
}

.management-dropdown-header:hover {
  background: rgba(255, 255, 255, 0.1);
}

.management-dropdown-arrow {
  transition: transform 0.3s;
  font-size: 12px;
}

.management-dropdown-arrow.open {
  transform: rotate(180deg);
}

.management-dropdown-content {
  display: none;
}

.management-dropdown-content.open {
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 75vh;
  overflow-y: auto;
  border: 2px solid rgba(255, 255, 255, 0.35);
  margin-top: 0;
  display: grid;
  grid-template-columns: 320px minmax(260px, 1fr);
  gap: 0;
  position: absolute;
  left: 0;
  top: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(15px);
  border-radius: 0 12px 12px 12px; /* Round all corners except top-left */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  z-index: 10;
}

.management-section {
  padding: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.management-section.full-width {
  grid-column: 1 / -1; /* Spans both columns */
}

.management-section.left-column {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.management-section:last-child {
  border-bottom: none;
}

.management-section-title {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-weight: 600;
}

.management-btn {
  width: 100%;
  height: 40px;
  padding: 10px 15px;
  margin-bottom: 8px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
}

.management-btn:last-child {
  margin-bottom: 0;
}

.management-btn.add {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  justify-content: center;
}

.management-btn.add:hover {
  background: linear-gradient(135deg, #5fbcff 0%, #10ffff 100%);
  transform: translateY(-2px);
}

.management-btn.add .btn-icon {
  margin-right: 6px;
}

.management-btn.remove {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
}

.management-btn.remove:hover {
  background: linear-gradient(135deg, #ff7b7b 0%, #fe6a7f 100%);
  transform: translateY(-2px);
}

.management-btn.rename {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  color: #333;
}

.management-btn.rename:hover {
  background: linear-gradient(135deg, #b8fdfa 0%, #ffe6f3 100%);
  transform: translateY(-2px);
}

.management-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.management-btn.restart {
  background: linear-gradient(135deg, #444 0%, #222 100%);
  color: white;
  justify-content: center;
}

.management-btn.restart:hover {
  background: linear-gradient(135deg, #555 0%, #333 100%);
  transform: translateY(-2px);
}


.btn-icon {
  font-size: 16px;
}

.rename-input-container {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.rename-input-container.active {
  display: flex;
}

.rename-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 13px;
  outline: none;
}

.rename-input:focus {
  border-color: rgba(79, 172, 254, 0.8);
}

.rename-buttons {
  display: flex;
  gap: 8px;
  padding-bottom: 8px;
}

.rename-buttons button {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

.rename-confirm {
  background: #4facfe;
  color: white;
}

.rename-confirm:hover {
  background: #5fbcff;
}

.rename-cancel {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.rename-cancel:hover {
  background: rgba(255, 255, 255, 0.3);
}

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-identity-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr) auto; /* 5 colors + name pill */
  gap: 8px;
  align-items: center;
}

.color-identity-name {
  width: 100px;                 /* 🔒 fixed width */
  height: 32px;
  display: flex;                /* center text */
  align-items: center;
  justify-content: center;

  padding: 0 12px;
  margin-left: auto;

  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;

  font-weight: 700;
  font-size: 13px;
  color: white;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.color-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px; /* ← pill shape */
  font-weight: 700;
  font-size: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.5);
  color: white;
  cursor: pointer;
  transition: 
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.1s ease;
  width: 100%;                  /* 🔥 fill column */
  justify-content: center;
}

.color-btn.active {
  border-color: white;
  box-shadow:
    0 0 6px rgba(255,255,255,0.6),
    0 0 12px rgba(255,255,255,0.35);
}

.color-btn:active {
  transform: scale(0.95);
}

.color-btn.white.active {
  box-shadow:
    0 0 6px rgba(255,255,255,0.9),
    0 0 14px rgba(255,255,255,0.6);
}

.color-btn.blue.active {
  box-shadow:
    0 0 6px rgba(30,144,255,0.9),
    0 0 14px rgba(30,144,255,0.6);
}

.color-btn.black.active {
  box-shadow:
    0 0 6px rgba(160,160,160,0.7),
    0 0 14px rgba(100,100,100,0.5);
}

.color-btn.red.active {
  box-shadow:
    0 0 6px rgba(255,80,80,0.9),
    0 0 14px rgba(255,80,80,0.6);
}

.color-btn.green.active {
  box-shadow:
    0 0 6px rgba(60,200,120,0.9),
    0 0 14px rgba(60,200,120,0.6);
}

.color-btn[data-color="W"] { background: #eee; color: #000; }
.color-btn[data-color="U"] { background: #1e90ff; }
.color-btn[data-color="B"] { background: #222; }
.color-btn[data-color="R"] { background: #c0392b; }
.color-btn[data-color="G"] { background: #27ae60; }

.color-dropdown {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.color-dropdown-header {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-size: 12px;
  transition: background 0.2s;
}

.color-dropdown-header:hover {
  background: rgba(255, 255, 255, 0.1);
}

.color-dropdown-arrow {
  transition: transform 0.3s;
  font-size: 10px;
}

.color-dropdown-arrow.open {
  transform: rotate(180deg);
}

.color-dropdown-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.color-dropdown-content.open {
  max-height: 40vh;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.color-dropdown-icon {
  width: 5%;
}

.color-option {
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid transparent;
}

.color-option:hover {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(255, 255, 255, 0.5);
}

.color-option.active {
  background: rgba(79, 172, 254, 0.2);
  border-left-color: rgba(79, 172, 254, 1);
}

.color-dots {
  display: flex;
  gap: 3px;
  min-width: 60px;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.color-dot.white { background: #FFFFFF; }
.color-dot.blue { background: #4DA6FF; }
.color-dot.black { background: #8A8A8A; }
.color-dot.red { background: #FF6B47; }
.color-dot.green { background: #4CAF50; }
.color-dot.gold { background: linear-gradient(135deg, #FFD700, #FFA500); }

.color-option-name {
  flex: 1;
  font-size: 11px;
}

.counter-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.counter-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;              /* 🔒 fixed height */
  padding: 8px 10px;
  white-space: nowrap;           /* 🔒 prevent wrapping */
  overflow: hidden;              /* 🔒 contain content */
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  transition: background 0.2s;
  color: white;
  min-width: 200px;
}

.counter-toggle-item input:disabled + .counter-label {
  opacity: 0.6;
  cursor: not-allowed;
}

.counter-toggle-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.counter-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4facfe;
  flex-shrink: 0;
}

.counter-label {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 8px;
}

.counter-icon-preview {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  object-fit: contain;
  opacity: 0.7;
}

.player-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.player-action-row .management-btn {
  width: 100%;
  margin-bottom: 0;
  justify-content: center;
  padding: 10px 8px;
  font-size: 12px;
}

.mtg-ring-counter .nav-controls {
  margin-top: clamp(16px, 4vw, 28px);
}

/* Tighten label-to-panel spacing */
.mtg-ring-counter .player-name-label-external {
  margin-top: 6px;
}

@media (orientation: portrait) {
	body {
	  background-image: url('/mtg/images/generic-background-portrait.png');
	}
	
	/*.quick-action-btn {
		flex: 1;
		width: 120px !important;
	}*/
}

@media (max-height: 640px) {
  .dashboard-intro {
    display: none;
  }
}

@media (max-width: 360px) and (min-height: 640px) {
  /* Force the entire MTG system to be smaller */
  .mtg-ring-counter #menu {
	width: 240px !important;
	height: 240px !important;
	max-width: 240px !important;
	max-height: 240px !important;
  }
  
  .mtg-ring-counter #innerCircle {
	width: 180px !important;
	height: 180px !important;
	max-width: 180px !important;
	max-height: 180px !important;
  }
  
  .carousel-container {
	padding: 60px 20px 120px 20px; /* More generous padding */
  }
  
  .app-container {
	width: 240px !important;
	height: 240px !important;
	min-width: 240px !important;
	min-height: 240px !important;
	max-width: 240px !important;
	max-height: 240px !important;
  }
}

/* Also update the general 360px rule to be more restrictive */
@media (max-width: 360px) {
  .carousel-container {
	padding: 50px 20px 100px 20px; /* Increase side padding */
  }
  
  /* Force smaller overall sizing */
  .mtg-ring-counter #menu {
	max-width: 280px !important;
	max-height: 280px !important;
  }
  
  .app-container {
	width: min(80vw, 280px) !important; /* Further reduced */
	height: min(80vw, 280px) !important;
	max-width: 280px !important;
	max-height: 280px !important;
  }
}

@media (max-width: 375px) {
  .player-management {
	position: fixed;
	top: 5px;
	left: 5px;
	width: 80px; /* Keep narrow */
	z-index: 2000;
  }
  
  .quick-action-btn {
	flex: 1;
	padding: 4px 2px;
	font-size: 7px;
	min-height: 30px;
	border-radius: 4px;
  }
  
  .quick-action-icon {
	font-size: 16px; /* Keep icons readable */
  }
  /*
  .quick-action-label {
	display: none; 
  }*/
  
  .management-dropdown-header {
	padding: 4px 6px;
	font-size: 8px;
	line-height: 1.1;
  }
  
  .management-dropdown-content.open {
	max-height: 40vh;
	width: 150px; /* Expand dropdown when open */
	margin-left: -35px;
  }
  
  /* Less left margin needed since quick actions are more compact */
  .carousel-container {
	padding: 20px 10px 100px 85px;
  }
  
  .app-container {
	min-width: 150px !important;
	min-height: 150px !important;
	max-width: 180px !important;
  }
}

@media (max-width: 480px) {
	.app-container {
		min-width: 250px !important;
		min-height: 250px !important;
	}
	
	.carousel-container {
		padding: 80px 20px 160px 20px;
	}

    .player-management {
        width: 100vw;
        left: 0;
        padding: 0;
    }

  .color-identity-name {
    width: 100px;
    font-size: 12px;
  }
  
    .quick-actions {
        display: grid;
        width: 100%;
        max-width: none;
    }
    
    .quick-action-btn {
        width: 100% !important;
        max-width: none;
        min-width: 0;
        padding: 10px 0;
    }
    
    .quick-action-icon {
        width: 32%; 
    }
    
    .quick-action-label {
        font-size: 9px;
        line-height: 1.1;
    }
  
	.management-dropdown-header {
		padding: 8px 10px;
		font-size: 12px;
	}
	
	.management-section {
		padding: 10px;
	}

	.management-dropdown {
		background: rgba(0, 0, 0, 0.98);
	}

	.management-dropdown-content.open {
		max-height: 90vh;
		overflow-y: auto;
	}
}

@media (max-width: 768px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    body {
      background-image: url('/mtg/images/generic-background-portrait.png');
    }

    body::before {
      background-image: url('/mtg/images/generic-background-portrait.png');
    }

    body.modal-open {
        overflow: hidden;
    }
    
    body:not(.modal-open) {
        overflow: hidden;
    }
    
    .modal-overlay {
      position: fixed;
      inset: 0;               /* top:0 right:0 bottom:0 left:0 */
      background: rgba(0,0,0,0.75);
      z-index: 99999;         /* higher than EVERYTHING */
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: auto;
    }
  
    .app-wrapper {
        height: 100dvh;
        min-height: 100svh;
        gap: clamp(8px, 2vh, 16px);
    }
  
    .mtg-dashboard,
    .game-dashboard {
        min-height: 100svh;
        height: auto;
    }

    .dashboard-intro {
        display:none;
    }
  
    .mtg-dashboard {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }

    .color-btn {
        height: 30px;
        padding: 0 12px;
        font-size: 13px;
    }
  
    .nav-controls {
        bottom: calc(24px + env(safe-area-inset-bottom));
        padding-top: 2px;
    }
    
    .inactive-player-container {
      gap: 0px !important;
      padding-top: 0px;
    }
    
	.management-dropdown-content.open {
        position: absolute !important;
        top: 100%;
        left: 0;
        width: 100vw !important;
        max-height: calc(100dvh - 120px);
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        border-radius: 0 0 12px 12px;
	}

	.management-section.left-column {
		border-right: none;
		border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	}

    .management-section-title {
        margin-bottom: 4px;
        margin-top: 8px;
        font-size: 10px;
        letter-spacing: 0.06em;
    }
  
	.management-dropdown-header {
		width: 250px
	}
	
    .management-dropdown {
        width: 100% !important;
        border-radius: 0 0 14px 14px;
    }

    .management-btn {
        height: 36px;
        margin-bottom: 4px;
    }

    .player-management {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        padding: 0;
    }

    /* Stack sections vertically */
    .management-section {
        width: 100%;
        border-right: none !important;
        padding: 6px 10px;
    }
    
    /* Make counters a grid */
    .counter-toggles {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        overflow-x: hidden !important;
    }
    
    /* Make each counter card readable */
    .counter-toggle-item {
        display: grid;
        grid-template-columns: 18px 1fr 18px;
        gap: 6px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 6px 8px;
        min-height: 36px;
        font-size: 12px;
        white-space: nowrap;
        min-width: 0 !important; 
        width: 100%;
        overflow: hidden;
    }
    
    .counter-label {
        font-size: 11px;
        min-width: 0;
        max-width: 80px; 
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .counter-icon-preview {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .player-action-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 4px;
    }

    .player-action-row .management-btn.remove {
      opacity: 0.9;
    }

    .rename-input-container {
      margin-top: 6px;
    }

    .player-action-row .management-btn {
        height: 38px;
        font-size: 12px;
        padding: 8px;
        justify-content: center;
        white-space: nowrap;
    }

    .restart-game-btn {
        margin-top: 10px;
        padding: 12px;
        font-size: 13px;
        opacity: 0.9;
    }
    
    .restart-game-btn:active {
        transform: scale(0.98);
    }

    .management-btn.restart {
        height: 36px;
        font-size: 12px;
        opacity: 0.85;
        margin-top: 6px;
    }

    .management-section + .management-section {
        border-top: 1px solid rgba(255,255,255,0.08);
    }
  
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        column-gap: 4vw;
        padding-inline: 4vw;
        width: 100%;
        max-width: none !important;
        box-sizing: border-box;
    }
    
    .quick-action-btn {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        padding: 10px 0;
    }
    
    .quick-action-icon {
        width: 32%; 
    }
    
    .quick-action-label {
        font-size: 9px;
        line-height: 1.1;
        text-align: center;
    }
    
    .modal-overlay {
        align-items: flex-end;  /* feels more native on mobile */
    }
  
    .modal {
        width: 100%;
        max-width: none;
        border-radius: 16px 16px 0 0;
    }
    
    body.mtg-dashboard .mtg-legal-zone {
        display: none !important;
    }
}


@media (orientation: landscape) and (max-width: 900px) {
  .carousel-container {
    padding: 5vh 20vw 5vh 20vw !important;
  }
  
  .app-container {
    min-width: 0 !important; /* Remove minimum - let it shrink */
    min-height: 0 !important; /* Remove minimum - let it shrink */
    max-width: calc(70vw - 30vw) !important; /* 70% minus sidebars */
    max-height: 85vh !important;
    width: calc(70vw - 30vw) !important; /* Force specific size */
    height: auto !important;
    aspect-ratio: 1; /* Keep it square */
  }
  
  .player-management {
    width: 15vw;
    min-width: 100px;
    top: 1vh;
    left: 1vw;
  }
  
  .quick-actions {
    flex-direction: column;
    gap: 0.5vh;
  }
  
  .quick-action-btn {
    padding: 1vh 0.5vw;
    font-size: max(9px, 1.8vh);
    min-height: 6vh;
  }
  
  .quick-action-icon {
    font-size: max(14px, 2.5vh);
  }
  /*
  .quick-action-label {
    display: none;
  }*/
  
  .management-dropdown {
    width: 15vw;
    min-width: 100px;
  }
  
  .management-dropdown-header {
    padding: 1vh 0.5vw;
    font-size: max(9px, 1.8vh);
  }
  
  .management-dropdown-content.open {
    width: 30vw;
    min-width: 200px;
    grid-template-columns: 1fr;
  }
  
  .management-section.left-column {
    border-right: none;
  }
  
  .nav-controls {
    position: fixed !important;
    bottom: auto !important; /* Critical: remove bottom positioning */
    top: 2vh !important;
    right: 1vw !important;
    left: auto !important;
    transform: none !important;
    width: 15vw;
    min-width: 100px;
    height: 96vh;
    flex-direction: column;
    padding: 0 !important; /* Remove any padding */
    margin: 0 !important;
  }
  
  .inactive-players-row {
    flex-direction: column;
    gap: 1vh;
    padding: 1vh 0.5vw;
    overflow-y: auto;
    margin-bottom: clamp(16px, 3vh, 28px);
  }
  
  .player-wrapper.inactive {
    transform: scale(0.25);
    margin-bottom: 1vh;
  }
  
  .player-name-label {
    transform: translateX(-50%) scale(2);
    font-size: max(10px, 2vh);
    margin-bottom: 0.5vh;
  }
}

.entry-content .app-wrapper,
.site-content .app-wrapper,
article .app-wrapper,
.content-area .app-wrapper {
  max-width: none !important;
  width: 100% !important;
}

/* Override WordPress image and container defaults */
.entry-content img,
.site-content img {
  max-width: 100%;
  height: auto;
}

/* But exempt MTG counter elements from WordPress image rules */
.mtg-ring-counter img,
.mtg-ring-counter svg,
.mtg-ring-counter .app-container,
.mtg-ring-counter * {
  max-width: none !important;
}

/* Ensure carousel takes available space */
body .carousel-container {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  overflow: hidden !important;
  min-height: 0 !important;
  padding: 20px 5vw !important;
}

/* Remove any WordPress padding/margin on the main container */
body .site-main .app-wrapper,
body .site-content .app-wrapper,
body main .app-wrapper {
  margin: 0 !important;
  padding: 10px !important;
}

/* Override common WordPress theme max-widths */
body .entry-content,
body .site-content,
body .content-area {
  max-width: none !important;
}

/* Specific fixes for popular WordPress themes */

/* Twenty Twenty-One / Twenty Twenty-Two */
.is-root-container .app-wrapper {
  max-width: 100% !important;
}

/* Astra Theme */
.ast-container .app-wrapper {
  max-width: 100% !important;
}

/* GeneratePress */
.inside-article .app-wrapper {
  max-width: 100% !important;
}

/* OceanWP */
#content .app-wrapper {
  max-width: 100% !important;
}

/* Ensure active player display is properly sized */
body .active-player-display {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Critical: Force app-container to maintain size */
body .mtg-ring-counter .app-container {
  min-width: min(480px, 90vw) !important;
  min-height: min(480px, 90vh) !important;
  max-width: min(90vw, 90vh, 600px) !important;
  max-height: min(90vh, 90vw, 600px) !important;
  width: auto !important;
  height: auto !important;
}

/* Additional WordPress admin bar compensation */
body.admin-bar .app-wrapper {
  top: 32px !important;
  height: calc(100vh - 32px) !important;
}

@media screen and (max-width: 782px) {
  body.admin-bar .app-wrapper {
    top: 46px !important;
    height: calc(100vh - 46px) !important;
  }
}

/* Ensure no WordPress lazy loading interferes */
.mtg-ring-counter img {
  loading: eager !important;
}



@media (min-width: 769px) {
  html, body {
    overflow: hidden;
  }
 
  .quick-actions {
    max-width: 420px; /* was 280px */
    gap: 12px;
  }

  .quick-action-btn {
    max-width: none;
    min-width: 90px;
    padding: 14px 10px;
  }

  .quick-action-label {
    font-size: 11px;
    white-space: nowrap; /* force single line */
  }

  .management-dropdown-content.open {
    width: 620px; /* more breathing room */
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
  }

  .management-section.left-column {
    border-right: 1px solid rgba(255,255,255,0.15);
  }
  
  .counter-toggles {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .counter-toggle-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    min-height: 42px;
  }

  .counter-label {
    font-size: 13px;
  }

  .counter-icon-preview {
    width: 22px;
    height: 22px;
    opacity: 0.85;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  
  padding: env(safe-area-inset-top)
           env(safe-area-inset-right)
           env(safe-area-inset-bottom)
           env(safe-area-inset-left);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: #121212;
  border-radius: 16px;
  padding: 20px;
  max-width: 92vw;
  width: 420px;
  color: #fff;

  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: #fff;
}

.modal p {
  font-size: 14px;
  opacity: 0.85;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

#restartModal .modal h3 {
  color: #f1f1f1;
  font-weight: 600;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
  text-align: center;
}

#restartModal .modal h3::after {
  content: '';
  display: block;
  width: 42px;
  height: 2px;
  margin: 8px auto 0;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
}

#restartModal .modal p {
  color: #ccc;
  text-align: center;
  margin-bottom: 20px;
}

#restartModal .modal {
  background: linear-gradient(
    180deg,
    #181818 0%,
    #0f0f0f 100%
  );
}

.btn {
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.btn.primary {
  background: #2563eb;
  color: white;
}

.btn.danger {
  background: #991b1b;
  color: white;
}

.btn.secondary {
  background: #2a2a2a;
  color: #ddd;
}

.ring-restart {
  animation: ringRestartPulse 400ms ease-in-out;
  box-shadow: 0 0 0 rgba(255,255,255,0);
}

@keyframes ringRestartPulse {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
  }

  40% {
    transform: scale(0.92);
    opacity: 0.3;
    filter: blur(1px);
  }

  100% {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
  }
}