:root {
  /* Classic Olive Felt Theme */
  --bg-table: radial-gradient(circle at 50% 50%, #5d6453 0%, #3e4438 100%);
  --text-light: #ffffff;
  --text-dim: #dce3d8;
  --accent-green: #aacc88;
  --panel-bg: rgba(35, 40, 32, 0.94);
  --panel-border: rgba(255, 255, 255, 0.18);
  --font-main: 'Plus Jakarta Sans', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

img, canvas {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-main);
  background: var(--bg-table);
  color: var(--text-light);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Floating Controls Bar */
.floating-brand-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 40px;
  padding: 6px 18px 6px 6px;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.game-brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.brand-puzzle-icon {
  width: 32px !important;
  height: 32px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-puzzle-icon svg {
  width: 32px !important;
  height: 32px !important;
}

.floating-tool-dock {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 40px;
  padding: 6px 14px;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.floating-utils-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 40px;
  padding: 6px 14px 6px 18px;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.daily-streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffd166;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.daily-streak-pill:hover {
  background: rgba(255, 209, 102, 0.18);
  border-color: rgba(255, 209, 102, 0.4);
  transform: translateY(-1px);
}

.daily-streak-pill.active {
  background: rgba(255, 209, 102, 0.15);
  border-color: rgba(255, 209, 102, 0.5);
  color: #ffd166;
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.25);
}

.daily-tool-btn {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.3);
}

.daily-tool-btn:hover {
  background: rgba(255, 209, 102, 0.2);
  border-color: #ffd166;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.4);
}

/* Side Drawer Categories Navigation List */
.drawer-category-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.drawer-cat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.drawer-cat-chip:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--accent-green);
  color: var(--accent-green);
  transform: translateY(-1px);
}

/* Challenge Banner Pill */
.challenge-banner-pill, .daily-challenge-banner-pill {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(26, 32, 22, 0.95);
  border: 1px solid var(--accent-green);
  border-radius: 30px;
  padding: 8px 18px;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: pulseChallenge 2s infinite ease-in-out;
}

@keyframes pulseChallenge {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 8px 30px rgba(170, 204, 136, 0.4); }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0) scale(0.95);
}

.icon-btn.active {
  background: var(--accent-green);
  color: #1a2015;
  box-shadow: 0 0 12px rgba(170, 204, 136, 0.5);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.timer-display {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-light);
  letter-spacing: 0.05em;
}

/* Floating Ad Banner Container */
.floating-ad-banner {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 2px 10px 3px;
  backdrop-filter: blur(20px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: min(728px, 92vw);
  max-height: 56px;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

body.is-dragging-piece .floating-ad-banner {
  opacity: 0.12;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.ad-tag {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 1px;
  line-height: 1;
}

/* Main Workspace Canvas */
.workspace-area {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  cursor: default;
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Reference Image Preview Thumbnail Overlay */
.preview-thumbnail {
  position: absolute;
  top: 76px;
  right: 16px;
  width: 180px;
  height: 120px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  background: #000;
  z-index: 20;
  cursor: pointer;
  display: none;
  transition: transform 0.2s ease;
}

.preview-thumbnail:hover {
  transform: scale(1.05);
}

.preview-thumbnail img, .preview-thumbnail canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Slide-Over Side Menu Drawer */
.side-menu-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(340px, 88vw);
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(24px);
  box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100vh;
}

.side-menu-drawer.open {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
}

.menu-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.section-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 12px 0 8px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.diff-chip {
  padding: 8px 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.diff-chip:hover {
  background: rgba(255, 255, 255, 0.18);
}

.diff-chip.active {
  background: var(--accent-green);
  color: #1a2015;
  font-weight: 800;
  border-color: transparent;
}

.menu-btn {
  width: 100%;
  padding: 10px 14px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.menu-btn-primary {
  background: var(--accent-green);
  color: #1a2015;
  font-weight: 800;
  border: none;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 75px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* Bottom Attribution Badges */
.photo-credit-badge, .legal-links-badge {
  position: fixed;
  bottom: 10px;
  z-index: 50;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.74rem;
  color: var(--text-dim);
  backdrop-filter: blur(16px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

.photo-credit-badge { right: 16px; }
.legal-links-badge { left: 16px; gap: 8px; }

.photo-credit-badge a, .legal-links-badge a {
  color: var(--accent-green);
  text-decoration: none;
  font-weight: 700;
}

.photo-credit-badge a:hover, .legal-links-badge a:hover {
  text-decoration: underline;
}

body.is-dragging-piece .photo-credit-badge,
body.is-dragging-piece .legal-links-badge {
  opacity: 0.12;
  pointer-events: none;
}

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

/* Responsive Design Media Queries */
@media (max-width: 768px) {
  /* Row 1: Top-Left Brand Bar & Top-Right Utilities Bar */
  .floating-brand-bar {
    top: 10px;
    left: 10px;
    padding: 4px 10px 4px 4px;
    gap: 6px;
    z-index: 70;
  }
  
  .game-brand-title span {
    display: none;
  }

  .floating-utils-bar {
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    gap: 6px;
    z-index: 70;
  }

  /* Row 2: Floating Tool Dock sits cleanly in its own row below Row 1 */
  .floating-tool-dock {
    top: 54px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 65;
    padding: 4px 10px;
    gap: 4px;
    max-width: 96vw;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .floating-tool-dock::-webkit-scrollbar {
    display: none;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .icon-btn svg {
    width: 20px;
    height: 20px;
  }

  .timer-display {
    font-size: 0.85rem;
  }

  .floating-ad-banner {
    max-width: min(728px, 94vw);
    bottom: 6px;
    padding: 2px 6px;
  }

  .photo-credit-badge {
    bottom: 68px;
    right: 10px;
    left: auto;
    transform: none;
    padding: 4px 10px;
    font-size: 0.68rem;
    max-width: 90vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .legal-links-badge {
    display: none;
  }

  .preview-thumbnail {
    top: 102px;
    right: 10px;
    width: 120px;
    height: 80px;
  }

  .toast {
    bottom: 115px;
  }
}

@media (max-width: 480px) {
  .floating-brand-bar {
    top: 8px;
    left: 8px;
    padding: 3px 8px 3px 3px;
  }

  .floating-utils-bar {
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    gap: 4px;
  }

  .floating-tool-dock {
    top: 54px;
    padding: 4px 8px;
    gap: 4px;
    border-radius: 30px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  .photo-credit-badge {
    bottom: 68px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    font-size: 0.65rem;
  }
}
