:root {
  /* Cute & Cozy Pastel Theme Colors */
  --bg-warm: #fcf6ee;
  --bg-gradient: linear-gradient(135deg, #fdfbf7 0%, #faecd8 100%);
  --primary-peach: #ff9f80;
  --primary-peach-hover: #ff8c66;
  --secondary-mint: #a2e8dd;
  --secondary-mint-hover: #88dfd2;
  --wool-red: #ff6b6b;
  --wool-yellow: #fecb2f;
  --wool-blue: #4dabf7;
  --wool-green: #51cf66;
  --wool-purple: #cc5de8;
  
  --text-dark: #4a3e3d;
  --text-light: #8b7a78;
  --glass-bg: rgba(255, 255, 255, 0.45);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 12px 32px rgba(220, 190, 160, 0.15);
  
  --font-family-title: 'Outfit', 'Noto Sans KR', sans-serif;
  --font-family-body: 'Noto Sans KR', 'Outfit', sans-serif;
}

/* Base Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family-body);
  color: var(--text-dark);
  background: var(--bg-warm);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ambient Background Decorations */
.ambient-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-gradient);
  z-index: 1;
  overflow: hidden;
}

/* Window with Snow Falling */
.window-pane {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 180px;
  height: 140px;
  background: linear-gradient(to bottom, #74abe2, #556c82);
  border: 8px solid #f2e3d5;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1), inset 0 0 20px rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}
.window-pane::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: #f2e3d5;
}
.window-pane::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 4px;
  background: #f2e3d5;
}

.weather-particle {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(white 1px, transparent 0),
              radial-gradient(white 2px, transparent 0);
  background-size: 20px 20px, 30px 30px;
  background-position: 0 0, 10px 15px;
  animation: fall 10s linear infinite;
  opacity: 0.6;
}

@keyframes fall {
  0% { background-position: 0 0, 10px 15px; }
  100% { background-position: 20px 200px, 40px 150px; }
}

/* Cozy Fireplace */
.fireplace {
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 200px;
  height: 150px;
  background: #d9ab82;
  border: 12px solid #b88660;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.05);
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.fireplace::before {
  content: '';
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 20px;
  background: #3e2723;
}
.fire-glow {
  position: absolute;
  bottom: 20px;
  width: 100px;
  height: 80px;
  background: radial-gradient(circle, rgba(255,140,0,0.8) 0%, rgba(255,69,0,0) 70%);
  filter: blur(10px);
  animation: flicker 2s infinite alternate;
}
.fire-flames {
  position: absolute;
  bottom: 20px;
  width: 50px;
  height: 60px;
  background: #ff5722;
  border-radius: 50% 50% 20% 20% / 80% 80% 20% 20%;
  animation: flameMove 0.8s infinite alternate;
  box-shadow: 0 -10px 20px #ffeb3b, 0 -4px 10px #ff9800;
}

@keyframes flicker {
  0% { opacity: 0.8; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}
@keyframes flameMove {
  0% { transform: scaleX(0.9) rotate(-2deg); }
  100% { transform: scaleX(1.1) rotate(2deg) scaleY(1.05); }
}

/* Rug decoration */
.rug-decoration {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 120px;
  background: #ebd8c8;
  border: 6px dashed #dcbfa8;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

/* Sleeping Cat */
.sleeping-cat-decoration {
  position: absolute;
  bottom: 10px;
  right: 15%;
  width: 80px;
  height: 50px;
  background: #e67e22;
  border-radius: 40px 40px 10px 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  animation: catBreathe 3s ease-in-out infinite;
}
.sleeping-cat-decoration::after {
  content: 'Zzz';
  position: absolute;
  top: -20px;
  right: 10px;
  font-family: var(--font-family-title);
  font-size: 11px;
  color: var(--text-light);
  animation: floatZ 3s infinite;
}

@keyframes catBreathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.08) translateY(-2px); }
}
@keyframes floatZ {
  0% { opacity: 0; transform: translateY(5px) scale(0.8); }
  50% { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-15px) scale(1.2); }
}

/* Plant decoration */
.plant-decoration {
  position: absolute;
  bottom: 0;
  right: 5%;
  width: 60px;
  height: 100px;
  background: linear-gradient(to top, #2e7d32, #4caf50);
  border-radius: 30px 30px 0 0;
  transform-origin: bottom center;
  animation: sway 6s ease-in-out infinite;
}
.plant-decoration::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 30px;
  background: #bcaaa4;
  border-radius: 4px;
}

@keyframes sway {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(2deg); }
}

/* Game Container and Layout */
.game-container {
  position: relative;
  z-index: 10;
  width: 95vw;
  max-width: 1200px;
  height: 92vh;
  max-height: 850px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 32px;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Game Header */
.game-header {
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
}

.game-title {
  font-family: var(--font-family-title);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 800;
  background: linear-gradient(135deg, #e05a30, #ff8c66);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Icon & Text Buttons */
.icon-btn, .text-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-dark);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}
.icon-btn:hover, .text-btn:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(224, 90, 48, 0.15);
}
.icon-btn:active, .text-btn:active {
  transform: translateY(0);
}
.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.text-btn {
  padding: 8px 16px;
  font-family: var(--font-family-title);
  font-weight: 700;
  border-radius: 20px;
  font-size: 14px;
}

/* Screens Setup */
.screen {
  flex: 1;
  display: none;
  position: relative;
  padding: 24px;
  overflow-y: auto;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* Start Screen Stylings */
#screenStart {
  justify-content: center;
  align-items: center;
  gap: 36px;
}

.logo-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-yarn-ball {
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at 30% 30%, var(--primary-peach) 30%, #e05a30 90%);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 10px 30px rgba(224, 90, 48, 0.3);
  animation: rollBounce 3s ease-in-out infinite;
}
.thread-swirl {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 90px;
  height: 90px;
  border: 4px dashed rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: rotateSwirl 8s linear infinite;
}
.logo-yarn-ball::after {
  content: '';
  position: absolute;
  bottom: -15px;
  right: -25px;
  width: 60px;
  height: 8px;
  background: rgba(0,0,0,0.1);
  border-radius: 50%;
  filter: blur(3px);
  animation: shadowScale 3s ease-in-out infinite;
}

@keyframes rollBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(15deg); }
}
@keyframes rotateSwirl {
  100% { transform: rotate(360deg); }
}
@keyframes shadowScale {
  0%, 100% { transform: scaleX(1); opacity: 1; }
  50% { transform: scaleX(0.7); opacity: 0.5; }
}

.main-logo-text {
  font-family: var(--font-family-title);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  color: var(--text-dark);
  margin-top: 16px;
  text-shadow: 0 4px 10px rgba(0,0,0,0.02);
}
.logo-subtext {
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  color: var(--text-light);
  margin-top: 8px;
  font-weight: 400;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

/* Button UI */
.btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: var(--font-family-body);
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-peach) 0%, #ff8c66 100%);
  color: white;
}
.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(255, 140, 102, 0.4);
}
.btn-primary:active {
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-dark);
}
.btn-secondary:hover {
  background: white;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}
.btn-secondary:active {
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%);
  color: white;
}
.btn-success:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(55, 178, 77, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #ff6b6b 0%, #f03e3e 100%);
  color: white;
}
.btn-danger:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(240, 62, 62, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, #fecb2f 0%, #f59f00 100%);
  color: var(--text-dark);
}
.btn-warning:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(245, 159, 0, 0.4);
}

.btn-large {
  padding: 18px 24px;
  font-size: 1.1rem;
  border-radius: 20px;
}
.btn:not(.btn-large) {
  padding: 12px 20px;
  font-size: 0.95rem;
  border-radius: 16px;
}

/* Card Panel & Glassmorphism container */
.card-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 28px;
  padding: 32px;
  max-width: 600px;
  width: 100%;
  margin: auto;
  text-align: center;
}
.card-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  font-weight: 800;
  color: var(--text-dark);
}

.how-to-content {
  text-align: left;
  margin-bottom: 28px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 10px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.how-to-content p {
  margin-bottom: 12px;
}
.how-to-content ul {
  padding-left: 20px;
  margin-bottom: 16px;
}
.how-to-content li {
  margin-bottom: 8px;
}

/* Gameplay Layout */
.play-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.hud-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hud-label {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hud-value {
  font-family: var(--font-family-title);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-dark);
}

.timer-hud {
  flex-direction: row;
  justify-content: space-between;
  gap: 12px;
  grid-column: span 1;
}
.timer-bar-container {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff6b6b, #ff8c66);
  border-radius: 4px;
  transition: width 0.1s linear;
}
.timer-text {
  min-width: 45px;
  text-align: right;
  font-size: 1.1rem;
}

/* Game Play Board Workspace */
.play-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 18px;
  min-height: 0; /* Important for grid scrolling */
  margin-bottom: 18px;
}

.workspace-panel {
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  padding: 18px;
  overflow: hidden;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.workspace-panel h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Customer Panel Styling */
.customer-station {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
}

.customer-bubble {
  background: white;
  border-radius: 16px;
  padding: 14px;
  position: relative;
  box-shadow: 0 6px 16px rgba(0,0,0,0.04);
  width: 100%;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: floatBubble 3s ease-in-out infinite;
}
.customer-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: white transparent;
  display: block;
  width: 0;
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.order-pattern {
  display: flex;
  gap: 6px;
}
.pattern-block {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);
  animation: scalePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards;
}

@keyframes scalePop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.order-item-desc {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 700;
  background: #f0e6df;
  padding: 2px 8px;
  border-radius: 10px;
}

.customer-avatar-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.customer-avatar {
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: idleBounce 2s ease-in-out infinite;
}
@keyframes idleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.patience-wrapper {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 120px;
}
.heart-icon {
  font-size: 14px;
}
.patience-track {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  overflow: hidden;
}
.patience-fill {
  height: 100%;
  width: 100%;
  background: #2ec4b6;
  border-radius: 4px;
  transition: width 0.1s linear, background-color 0.5s ease;
}

.customer-info {
  text-align: center;
}
.customer-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}
.customer-dialog {
  display: block;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  font-style: italic;
}

/* Loom Screen Panel (Center) */
.loom-panel {
  flex: 1;
}

.loom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.garment-type-badge {
  background: #fff3bf;
  color: #f59f00;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 12px;
  font-weight: 700;
  border: 1px solid rgba(245, 159, 0, 0.15);
}

.combo-text {
  font-family: var(--font-family-title);
  font-weight: 800;
  font-size: 13px;
  color: #ff8c66;
  background: rgba(255, 140, 102, 0.1);
  padding: 4px 10px;
  border-radius: 12px;
  animation: pulse 1s infinite alternate;
  display: none;
}
@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.loom-visualizer-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  min-height: 480px;
  max-height: 520px;
  background-color: #ffd166; /* Yellow Brick background */
  background-image: 
    linear-gradient(90deg, #e76f51 2px, transparent 2px),
    linear-gradient(0deg, #e76f51 2px, transparent 2px);
  background-size: 40px 20px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.15);
  padding: 10px 4px;
}

.board-column {
  width: 20px;
  background: repeating-linear-gradient(
    to bottom,
    #ffd166 0px,
    #ffd166 18px,
    #e76f51 19px,
    #f4a261 20px,
    #f4a261 38px,
    #e76f51 39px
  );
  border: 3px solid #e76f51;
  border-radius: 6px;
  box-shadow: inset -2px 0 5px rgba(0,0,0,0.2), 2px 0 10px rgba(0,0,0,0.15);
  z-index: 8;
}
.column-left {
  margin-right: -4px;
}
.column-right {
  margin-left: -4px;
}

.knitting-board-outer {
  flex: 1;
  position: relative;
  background-color: #fcc2d7; /* Pink board base */
  border-top: 3px solid #ff85a2;
  border-bottom: 3px solid #ff85a2;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 18px 0 10px 0;
  z-index: 5;
}

.board-lace-trim {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 18px;
  z-index: 10;
}

/* Red bows in corners of the board */
.bow-corner {
  position: absolute;
  top: 2px;
  width: 32px;
  height: 24px;
  z-index: 12;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  /* Inline SVG for cute red bow */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 30'><ellipse cx='12' cy='12' rx='10' ry='7' fill='%23ff2222' stroke='%23aa0000' stroke-width='2' transform='rotate(-15 12 12)' /><ellipse cx='28' cy='12' rx='10' ry='7' fill='%23ff2222' stroke='%23aa0000' stroke-width='2' transform='rotate(15 28 12)' /><path d='M12,16 L4,28 L10,26 Z' fill='%23ff2222' stroke='%23aa0000' stroke-width='2' /><path d='M28,16 L36,28 L30,26 Z' fill='%23ff2222' stroke='%23aa0000' stroke-width='2' /><circle cx='20' cy='14' r='5' fill='%23dd0000' stroke='%23770000' stroke-width='2' /></svg>");
}
.bow-left {
  left: 4px;
}
.bow-right {
  right: 4px;
}

.knitting-grid-board {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(20, 1fr);
  width: 96%;
  height: 98%;
  gap: 0px; /* seamless knitted fabric */
  overflow: hidden;
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
  user-select: none;
  -webkit-user-select: none;
}

.stitch-cell {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  box-sizing: border-box;
}

/* Translucent overlay inside cell to create 3D texture over any color */
.stitch-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Guide dot overlay */
.stitch-cell.has-guide::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(0,0,0,0.3);
  pointer-events: none;
  box-shadow: 0 0 3px rgba(0,0,0,0.5);
  animation: guideBlink 1.5s infinite alternate;
}

@keyframes guideBlink {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Paint-by-Number Guide Hints */
.stitch-guide-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  pointer-events: none;
  opacity: 0.85;
  z-index: 5;
}

/* Pink guide color (eraser) needs dark text for readability */
.stitch-guide-hint.guide-color-0 {
  color: #4a3e3d;
  text-shadow: none;
  border: 1px solid rgba(0,0,0,0.25);
}

.golden-needle-bar {
  position: absolute;
  bottom: 8px;
  left: 2%;
  width: 96%;
  height: 7px;
  background: linear-gradient(to bottom, #ffe066 0%, #fcc419 50%, #e59900 100%);
  border: 1px solid #d94b2b;
  border-radius: 4px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.15);
  z-index: 15;
  pointer-events: none;
  transition: bottom 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
.pink-yarn-slider {
  position: absolute;
  left: 10px;
  top: -7px;
  width: 18px;
  height: 21px;
  background: radial-gradient(circle at 30% 30%, #ff8787 20%, #fa5252 90%);
  border: 1.5px solid #c92a2a;
  border-radius: 4px;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.2);
}

/* Minimap Preview Container inside Customer speech bubble */
.order-pattern-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.preview-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.5px;
}
.pattern-minimap {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(20, 1fr);
  width: 110px;
  height: 130px;
  gap: 0.5px;
  background-color: #ffd8a8; /* soft wood color */
  border: 2.5px solid #d8b48f;
  border-radius: 8px;
  padding: 3px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
}
.minimap-cell {
  width: 100%;
  height: 100%;
  border-radius: 1px;
  box-shadow: inset 0 -0.5px 0.5px rgba(0,0,0,0.1);
}

.knit-actions-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.btn-action {
  padding: 10px 14px !important;
  font-size: 0.85rem !important;
}

/* Wool Selection Panel (Right) */
.wool-panel {
  flex: 1;
}

.wool-baskets {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-content: start;
}

.basket {
  background: white;
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.02);
}
.basket:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}
.basket.active {
  border-color: var(--primary-peach);
  background: #fff8f5;
  box-shadow: 0 6px 14px rgba(255, 159, 128, 0.15);
}

.wool-ball {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 -6px 8px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: transform 0.2s ease;
}
.basket:hover .wool-ball {
  animation: ballSquish 0.3s ease;
}
@keyframes ballSquish {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1, 0.9); }
}

/* Ball thread strands texture */
.wool-ball::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    -30deg,
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.2) 4px,
    rgba(0, 0, 0, 0.1) 4px,
    rgba(0, 0, 0, 0.1) 8px
  );
}

.basket-hotkey {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--text-dark);
  color: white;
  font-family: var(--font-family-title);
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid white;
}

.basket-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
  margin-top: 6px;
}

.active-yarn-display {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.active-yarn-display #lblActiveYarn {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 700;
}
.active-yarn-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 -2px 2px rgba(0,0,0,0.2);
}
.active-yarn-name {
  font-size: 12px;
  font-weight: 700;
}

.btn-knit {
  width: 100%;
  padding: 12px 14px !important;
  border-radius: 16px !important;
  font-size: 0.9rem !important;
  box-shadow: 0 4px 10px rgba(255, 140, 102, 0.3) !important;
  margin-top: auto;
}

/* Play Screen Footer */
.play-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.btn-shop-toggle {
  border-radius: 20px !important;
  padding: 14px 22px !important;
  font-size: 1rem !important;
}

.hotkeys-legend {
  flex: 1;
  border-radius: 20px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
}
.legend-title {
  font-weight: 700;
  color: var(--text-light);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  padding-right: 16px;
  white-space: nowrap;
}
.shortcuts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--text-dark);
}
kbd {
  background: white;
  border: 1px solid #ced4da;
  border-bottom: 2.5px solid #adb5bd;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-family-title);
  font-size: 9px;
  font-weight: bold;
}

/* Modals System */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(40, 30, 25, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none; /* Controlled via JS */
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.active {
  display: flex;
}

.modal-content {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--glass-border);
  box-shadow: 0 16px 40px rgba(0,0,0,0.15);
  border-radius: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  animation: modalScaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}

@keyframes modalScaleUp {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-dark);
}
.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
}
.close-btn:hover {
  color: var(--text-dark);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Shop Modal Styles */
.shop-modal-content {
  max-width: 600px;
}
.shop-coins-hud {
  padding: 14px 24px;
  background: #fff8eb;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  font-weight: 700;
  font-size: 15px;
}
.shop-coins-val {
  color: #f59f00;
  font-size: 20px;
  font-family: var(--font-family-title);
  font-weight: 800;
}

.shop-items-grid {
  padding: 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.shop-item-card {
  background: white;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}
.shop-item-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.shop-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.shop-item-icon {
  font-size: 24px;
}
.shop-item-price {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 13px;
  color: #f59f00;
  background: rgba(253, 203, 47, 0.1);
  padding: 2px 8px;
  border-radius: 8px;
}
.shop-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}
.shop-item-desc {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.4;
  flex: 1;
}
.shop-item-card .btn {
  padding: 8px 12px !important;
  font-size: 0.8rem !important;
  border-radius: 10px !important;
  margin-top: 6px;
}

/* Leaderboard Modal Styles */
.lb-modal-content {
  max-width: 520px;
}
.game-over-summary {
  padding: 20px 24px;
  background: #fbf5f2;
  border-bottom: 1px solid rgba(224, 90, 48, 0.1);
  text-align: center;
}
.game-over-summary h3 {
  font-size: 15px;
  color: #ff6b6b;
  font-weight: 700;
  margin-bottom: 8px;
}
.summary-details {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 14px;
}
.score-highlight {
  color: #ff8c66;
  font-size: 20px;
}

.score-submission-form {
  padding: 18px 24px;
  background: #fff8f5;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  text-align: center;
}
.top-rank-congrats {
  font-weight: 700;
  color: #2ec4b6;
  font-size: 13px;
  margin-bottom: 6px;
}
.score-submission-form p:not(.top-rank-congrats) {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 10px;
}
.submit-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.submit-input-group input {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #ced4da;
  font-family: var(--font-family-body);
  font-size: 13px;
  outline: none;
  width: 160px;
}
.submit-input-group input:focus {
  border-color: var(--primary-peach);
}

.leaderboard-table-container {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  min-height: 200px;
  position: relative;
}

/* Spinner */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 10;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid rgba(0,0,0,0.05);
  border-top-color: var(--primary-peach);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}
.loading-spinner p {
  font-size: 12px;
  color: var(--text-light);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.leaderboard-table th, .leaderboard-table td {
  padding: 10px 14px;
  font-size: 13px;
}
.leaderboard-table th {
  border-bottom: 2px solid rgba(0,0,0,0.05);
  color: var(--text-light);
  font-weight: 700;
}
.leaderboard-table tr:not(:last-child) td {
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.leaderboard-table tbody tr:hover {
  background: rgba(255, 140, 102, 0.05);
}

/* Highlight rankings */
.leaderboard-table tbody tr:nth-child(1) td:first-child { color: #f59f00; font-weight: bold; }
.leaderboard-table tbody tr:nth-child(2) td:first-child { color: #adb5bd; font-weight: bold; }
.leaderboard-table tbody tr:nth-child(3) td:first-child { color: #d94b2b; font-weight: bold; }

/* Responsive Media Queries */
@media (max-width: 900px) {
  .play-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }
  .customer-panel, .wool-panel, .loom-panel {
    grid-column: span 1;
    max-height: 380px;
  }
  .loom-visualizer {
    min-height: 140px;
  }
  .game-container {
    height: 98vh;
    max-height: 900px;
  }
  .play-hud {
    grid-template-columns: repeat(2, 1fr);
  }
  .timer-hud {
    grid-column: span 2;
  }
  .play-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .hotkeys-legend {
    display: none; /* Hide hotkey helper on mobile to save space */
  }
}

@media (max-width: 580px) {
  .shop-items-grid {
    grid-template-columns: 1fr;
  }
  .play-hud {
    gap: 8px;
    margin-bottom: 12px;
  }
  .hud-item {
    padding: 8px 12px;
  }
  .hud-value {
    font-size: 1.1rem;
  }
  .screen {
    padding: 12px;
  }
  .btn-large {
    padding: 14px 20px;
    font-size: 1rem;
  }
  .window-pane, .fireplace, .sleeping-cat-decoration, .plant-decoration {
    display: none; /* Disable heavy background decorations on small mobile screens */
  }
}

/* Pulsing Active Needle Cursor */
.stitch-cell.active-needle {
  outline: 3px solid #ff2222;
  outline-offset: -1.5px;
  z-index: 10;
  box-shadow: 0 0 12px #ff2222, inset 0 0 6px rgba(255,255,255,0.8);
  animation: cursorPulse 0.6s infinite alternate;
}
@keyframes cursorPulse {
  0% { transform: scale(1); outline-color: #ff2222; box-shadow: 0 0 10px #ff2222; }
  100% { transform: scale(1.08); outline-color: #fcc419; box-shadow: 0 0 16px #fcc419; }
}

/* Floating Polaroid-style Pattern Card on Loom Visualizer */
.floating-pattern-preview {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #fffdf9;
  border: 3.5px solid #ebd8c8;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18), inset 0 0 10px rgba(0,0,0,0.02);
  z-index: 25;
  transform: rotate(3deg); /* Cute pin-board tilt */
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none; /* Make clicks pass through */
}

/* Hover effect */
.floating-pattern-preview:hover {
  opacity: 0.25;
  transform: scale(0.95) rotate(3deg);
}

.floating-preview-title {
  font-size: 8px;
  font-weight: 800;
  color: var(--text-light);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#loomPatternMinimap {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(20, 1fr);
  width: 56px;
  height: 70px;
  gap: 0.2px;
  background-color: #f6e0c6;
  border: 1px solid #d8b48f;
  border-radius: 4px;
  padding: 1.5px;
}

