/* Coffee Rush — bright yellow/orange eye-catching design */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* The HTML `hidden` attribute must always win, even when a section
   explicitly sets `display: flex` (welcome / game-over screens). */
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #ffd54a 0%, #ff8a3d 60%, #ff5a1f 100%);
  color: #3a1f00;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 14px;
}

.title {
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow:
    2px 2px 0 #b34a00,
    4px 4px 0 rgba(0, 0, 0, 0.15);
  margin-bottom: 6px;
}

.subtitle {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  color: #fff7e0;
  font-weight: 600;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

/* Rules — two compact scoring chips under the subtitle */
.rules {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 0;
}

.rule {
  font-size: clamp(0.85rem, 2.3vw, 0.95rem);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid #3a1f00;
  box-shadow: 0 3px 0 #3a1f00;
  white-space: nowrap;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

.rule strong {
  font-weight: 900;
}

.rule-normal {
  background: #b87333;
}

.rule-golden {
  background: linear-gradient(135deg, #ffd24a, #ffb000);
  color: #3a1f00;
  text-shadow: none;
  box-shadow: 0 3px 0 #3a1f00, 0 0 10px rgba(255, 210, 74, 0.6);
}

/* HUD */
.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 14px;
}

.hud-item {
  background: #fff;
  border: 3px solid #ff5a1f;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: 0 4px 0 #c44a00;
}

.hud-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b34a00;
  font-weight: 700;
}

.hud-value {
  display: block;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  color: #ff5a1f;
  line-height: 1.1;
  margin-top: 2px;
}

/* Difficulty badge shown during play */
.difficulty-badge {
  text-align: center;
  margin-bottom: 8px;
}

.difficulty-badge span {
  display: inline-block;
  background: rgba(255, 255, 255, 0.85);
  color: #b34a00;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 14px;
  border-radius: 999px;
  border: 2px solid #3a1f00;
  box-shadow: 0 3px 0 #3a1f00;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Controls */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.btn {
  font-size: 1.05rem;
  font-weight: 800;
  padding: 12px 22px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
  letter-spacing: 0.5px;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-large {
  font-size: 1.3rem;
  padding: 16px 36px;
}

.btn-primary {
  background: #2ec27e;
  color: #fff;
  box-shadow: 0 5px 0 #1e8a5a;
}

.btn-primary:hover {
  background: #36d18a;
}

.btn-primary:disabled {
  background: #8aa99a;
  box-shadow: 0 5px 0 #6c8a7c;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: #ff5a1f;
  border: 3px solid #ff5a1f;
  box-shadow: 0 4px 0 #c44a00;
}

.btn-secondary:hover {
  background: #fff3e0;
}

.btn-share {
  background: #ffdd00;
  color: #3a1f00;
  border: 3px solid #3a1f00;
  box-shadow: 0 4px 0 #2a1600;
}

.btn-share:hover {
  background: #ffe44a;
}

.copied-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 12px);
  background: #2ec27e;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 0 #1e8a5a;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1000;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.copied-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Play area */
.play-area {
  position: relative;
  flex: 1;
  min-height: 320px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.4), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.3), transparent 40%),
    #fff7e0;
  border: 4px dashed #ff5a1f;
  border-radius: 22px;
  overflow: hidden;
  margin-bottom: 14px;
  touch-action: manipulation;
}

.play-area.disabled .cup {
  pointer-events: none;
  opacity: 0.5;
  transform: scale(0.85);
}

.cup {
  position: absolute;
  width: 90px;
  height: 90px;
  border: none;
  background: radial-gradient(circle at 30% 30%, #ffe9b3, #f5b86a 70%, #b87333 100%);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 0 #6b3a14,
    0 12px 18px rgba(0, 0, 0, 0.25),
    inset 0 -6px 0 rgba(0, 0, 0, 0.1);
  transition: transform 0.12s ease;
  will-change: left, top, transform;
}

.cup.size-easy {
  width: 110px;
  height: 110px;
}

.cup.size-hard,
.cup.size-insane {
  width: 70px;
  height: 70px;
}

.cup.insane {
  animation: insane-wobble 0.6s ease-in-out infinite;
}

@keyframes insane-wobble {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(-8deg) brightness(1.05); }
}

.cup:hover {
  transform: scale(1.05);
}

.cup:active {
  transform: scale(0.92);
}

.cup.pop {
  animation: pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cup.golden {
  background: radial-gradient(circle at 30% 30%, #fffbe0, #ffe45a 55%, #ffb000 100%);
  box-shadow:
    0 8px 0 #6b3a14,
    0 12px 18px rgba(0, 0, 0, 0.25),
    inset 0 -6px 0 rgba(0, 0, 0, 0.1),
    0 0 0 4px #fff2a8,
    0 0 24px 6px #ffd24a,
    0 0 48px 12px rgba(255, 200, 40, 0.65);
  animation: golden-pulse 1.1s ease-in-out infinite;
  filter: saturate(1.4) brightness(1.05);
}

.cup.golden .cup-emoji {
  filter: drop-shadow(0 0 6px #fff7c2) drop-shadow(0 0 2px #fff2a8);
}

/* Sparkles — only visible when the cup is golden */
.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

.cup.golden .sparkles {
  display: block;
}

.spark {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 1.1rem;
  line-height: 1;
  transform-origin: center;
  animation: twinkle 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px #fff7c2);
}

.spark-1 { transform: translate(-50%, -50%) translate(  0px, -52px) rotate(  0deg) scale(1);   animation-delay: 0.00s; }
.spark-2 { transform: translate(-50%, -50%) translate( 52px,   0px) rotate( 25deg) scale(0.9); animation-delay: 0.30s; }
.spark-3 { transform: translate(-50%, -50%) translate(  0px,  52px) rotate(-15deg) scale(1.1); animation-delay: 0.60s; }
.spark-4 { transform: translate(-50%, -50%) translate(-52px,   0px) rotate( 10deg) scale(0.85); animation-delay: 0.90s; }

.cup-emoji {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

@keyframes pop {
  0%   { transform: scale(1) rotate(0deg); }
  40%  { transform: scale(1.35) rotate(-6deg); }
  70%  { transform: scale(0.92) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes golden-pulse {
  0%, 100% {
    box-shadow:
      0 8px 0 #6b3a14,
      0 12px 18px rgba(0, 0, 0, 0.25),
      inset 0 -6px 0 rgba(0, 0, 0, 0.1),
      0 0 0 4px #fff2a8,
      0 0 24px 6px #ffd24a,
      0 0 48px 12px rgba(255, 200, 40, 0.65);
  }
  50% {
    box-shadow:
      0 8px 0 #6b3a14,
      0 12px 18px rgba(0, 0, 0, 0.25),
      inset 0 -6px 0 rgba(0, 0, 0, 0.1),
      0 0 0 5px #fff8d0,
      0 0 34px 10px #ffe45a,
      0 0 64px 18px rgba(255, 210, 60, 0.85);
  }
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.35;
    transform-origin: center;
  }
  50% {
    opacity: 1;
  }
}

/* Floating "+1" / "+5" text that rises from the cup when clicked */
.float-text {
  position: absolute;
  font-weight: 900;
  font-size: 1.6rem;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  text-shadow:
    1px 1px 0 rgba(0, 0, 0, 0.25),
    0 0 6px rgba(0, 0, 0, 0.15);
  will-change: transform, opacity;
  animation: float-up 0.85s ease-out forwards;
}

.float-text.plus1 {
  color: #ffffff;
}

.float-text.plus5 {
  color: #ffd24a;
  font-size: 2.1rem;
  text-shadow:
    1px 1px 0 #6b3a14,
    0 0 8px #fff2a8,
    0 0 14px #ffd24a;
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, -10%) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1);
  }
}

/* Message */
.message {
  text-align: center;
  min-height: 1.6em;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
  margin-bottom: 10px;
}

.message.win {
  font-size: 1.3rem;
  color: #fff;
  text-shadow: 2px 2px 0 #b34a00;
  animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-4px); }
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  margin: 10px 0 18px;
}

.welcome-card {
  background: #fff;
  border: 4px solid #ff5a1f;
  border-radius: 22px;
  padding: 24px 20px;
  box-shadow: 0 8px 0 #c44a00;
  text-align: center;
  width: 100%;
  max-width: 520px;
}

.welcome-title {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  color: #ff5a1f;
  margin-bottom: 10px;
  text-shadow: 2px 2px 0 #ffd24a;
}

.welcome-text {
  color: #3a1f00;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 18px;
}

.difficulty-picker {
  margin-bottom: 18px;
}

.difficulty-label {
  font-weight: 800;
  color: #b34a00;
  margin-bottom: 10px;
  font-size: 1rem;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.difficulty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  background: #fff7e0;
  border: 3px solid #ff5a1f;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  color: #3a1f00;
  box-shadow: 0 4px 0 #c44a00;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.difficulty-btn:hover {
  background: #fff;
}

.difficulty-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c44a00;
}

.difficulty-btn.selected {
  background: linear-gradient(135deg, #ffd24a, #ffb000);
  border-color: #3a1f00;
  box-shadow: 0 4px 0 #3a1f00, 0 0 12px rgba(255, 210, 74, 0.7);
}

.diff-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.diff-name {
  font-size: 1.05rem;
  color: #ff5a1f;
}

.diff-desc {
  font-size: 0.78rem;
  color: #6b3a14;
  font-weight: 600;
}

.best-row {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: #fff7e0;
  border: 2px dashed #b34a00;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  color: #3a1f00;
}

.best-value {
  font-size: 1.3rem;
  color: #ff5a1f;
}

.reset-row {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.btn-reset {
  background: transparent;
  color: #b34a00;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border: 1.5px dashed #b34a00;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-reset:hover {
  background: #fff7e0;
  color: #3a1f00;
}

.btn-reset:active {
  transform: translateY(1px);
}

/* Game UI wrapper (hides hud+playArea when on welcome/game-over) */
.game-ui {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Countdown overlay (3, 2, 1, GO!) */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 22px;
  z-index: 50;
  pointer-events: none;
}

.countdown-text {
  font-size: clamp(4rem, 18vw, 8rem);
  font-weight: 900;
  color: #fff;
  text-shadow:
    4px 4px 0 #b34a00,
    8px 8px 0 rgba(0, 0, 0, 0.3);
  animation: countdown-pop 1s ease-out forwards;
}

.countdown-text.go {
  color: #2ec27e;
  font-size: clamp(5rem, 22vw, 10rem);
  text-shadow:
    4px 4px 0 #1e8a5a,
    8px 8px 0 rgba(0, 0, 0, 0.3);
}

@keyframes countdown-pop {
  0% { transform: scale(0.3); opacity: 0; }
  20% { transform: scale(1.3); opacity: 1; }
  60% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Combo display */
.combo-burst {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  color: #ff5a1f;
  background: #fff;
  padding: 6px 18px;
  border-radius: 999px;
  border: 3px solid #ff5a1f;
  box-shadow: 0 4px 0 #c44a00, 0 0 18px rgba(255, 90, 31, 0.5);
  pointer-events: none;
  z-index: 40;
  animation: combo-pop 0.6s ease-out forwards;
  white-space: nowrap;
}

.combo-burst.x-high {
  color: #b34a00;
  background: linear-gradient(135deg, #ffd24a, #ffb000);
  border-color: #3a1f00;
  box-shadow: 0 4px 0 #3a1f00, 0 0 22px rgba(255, 210, 74, 0.85);
}

@keyframes combo-pop {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  30% { transform: translateX(-50%) scale(1.25); opacity: 1; }
  70% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-20px) scale(0.9); opacity: 0; }
}

/* Game Over Screen */
.game-over-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  margin: 10px 0 18px;
}

.game-over-card {
  background: #fff;
  border: 4px solid #ff5a1f;
  border-radius: 22px;
  padding: 24px 20px;
  box-shadow: 0 8px 0 #c44a00;
  text-align: center;
  width: 100%;
  max-width: 520px;
  animation: card-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes card-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.game-over-title {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  color: #ff5a1f;
  margin-bottom: 16px;
  text-shadow: 2px 2px 0 #ffd24a;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.result-item {
  background: #fff7e0;
  border: 3px solid #ffd24a;
  border-radius: 14px;
  padding: 12px 8px;
  box-shadow: 0 3px 0 #b34a00;
}

.result-label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b34a00;
  font-weight: 800;
}

.result-value {
  display: block;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 900;
  color: #ff5a1f;
  line-height: 1.1;
  margin-top: 4px;
}

.result-value.final-score {
  color: #2ec27e;
  text-shadow: 1px 1px 0 #1e8a5a;
}

.rank-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #ffd24a, #ffb000);
  border: 3px solid #3a1f00;
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 0 #3a1f00, 0 0 16px rgba(255, 210, 74, 0.6);
}

.rank-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.rank-name {
  font-size: clamp(1.1rem, 3.5vw, 1.4rem);
  font-weight: 900;
  color: #3a1f00;
}

.achievements-section {
  margin-bottom: 12px;
}

.achievements-title {
  font-size: clamp(0.9rem, 2.6vw, 1.05rem);
  color: #b34a00;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
  text-align: left;
}

.achievements-count {
  display: inline-block;
  margin-left: 6px;
  background: #fff7e0;
  border: 2px solid #b34a00;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.8rem;
  color: #b34a00;
}

.achievements-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0;
}

.achievement-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #fff7e0;
  border: 2px solid #d4a86a;
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
  min-height: 92px;
  box-shadow: 0 2px 0 #b34a00;
  transition: transform 0.2s ease;
}

.achievement-tile.locked {
  background: #f0e6d2;
  border-color: #c4b48a;
  opacity: 0.55;
  filter: grayscale(0.7);
  box-shadow: 0 2px 0 #b34a00;
}

.achievement-tile.unlocked {
  background: linear-gradient(135deg, #fff4c2, #ffd24a);
  border-color: #3a1f00;
  box-shadow: 0 3px 0 #3a1f00;
}

.achievement-tile.newly-unlocked {
  animation: achievement-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achievement-emoji {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.15));
}

.achievement-tile.locked .achievement-emoji {
  filter: grayscale(1) brightness(0.9);
}

.achievement-name {
  font-size: clamp(0.6rem, 1.7vw, 0.72rem);
  font-weight: 800;
  color: #3a1f00;
  line-height: 1.1;
}

.achievement-tile.locked .achievement-name {
  color: #8a6b3a;
}

.achievement-req {
  font-size: clamp(0.55rem, 1.4vw, 0.65rem);
  font-weight: 700;
  color: #b34a00;
  line-height: 1.1;
  letter-spacing: 0.2px;
  margin-top: 1px;
}

.achievement-tile.unlocked .achievement-req {
  color: #3a1f00;
}

.achievement-tile.locked .achievement-req {
  color: #8a6b3a;
  opacity: 0.85;
}

@keyframes achievement-pop {
  0%   { transform: scale(0.6); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Toast that appears when new achievements are unlocked */
.achievement-toast {
  display: block;
  background: linear-gradient(135deg, #ffd24a, #ffb000);
  color: #3a1f00;
  font-weight: 900;
  font-size: clamp(0.95rem, 2.6vw, 1.1rem);
  padding: 10px 14px;
  border-radius: 14px;
  border: 3px solid #3a1f00;
  box-shadow: 0 5px 0 #3a1f00, 0 0 20px rgba(255, 210, 74, 0.6);
  margin: 0 0 12px 0;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
  animation: achievement-toast-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes achievement-toast-in {
  0%   { transform: translateY(-20px) scale(0.8); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.challenge-text {
  color: #b34a00;
  font-weight: 800;
  font-size: clamp(1rem, 3vw, 1.2rem);
  margin-bottom: 16px;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.1);
}

.game-over-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.game-over-actions .btn {
  width: 100%;
  max-width: 320px;
}

/* Sound toggle button (top-right) */
.sound-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #ff5a1f;
  box-shadow: 0 4px 0 #c44a00;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.sound-toggle:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c44a00;
}

.sound-toggle.muted {
  background: #fff7e0;
  opacity: 0.7;
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 8px;
}

.bmc-btn {
  display: inline-block;
  background: #ffdd00;
  color: #3a1f00;
  text-decoration: none;
  font-weight: 800;
  padding: 12px 22px;
  border-radius: 999px;
  border: 3px solid #3a1f00;
  box-shadow: 0 5px 0 #3a1f00;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.bmc-btn:hover {
  background: #ffe44a;
}

.bmc-btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #3a1f00;
}

.footer-note {
  margin-top: 10px;
  color: #fff7e0;
  font-size: 0.9rem;
  font-weight: 600;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

.footer-version {
  margin-top: 4px;
  color: rgba(255, 247, 224, 0.75);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .app {
    padding: 14px 12px 28px;
  }
  .play-area {
    min-height: 360px;
  }
  .cup {
    width: 84px;
    height: 84px;
  }
  .cup.size-easy {
    width: 104px;
    height: 104px;
  }
  .cup.size-hard,
  .cup.size-insane {
    width: 64px;
    height: 64px;
  }
  .cup-emoji {
    font-size: 2.6rem;
  }
  .btn {
    padding: 12px 18px;
    font-size: 1rem;
  }
  .difficulty-options {
    grid-template-columns: 1fr 1fr;
  }
  .achievements-list {
    grid-template-columns: repeat(3, 1fr);
  }
  .sound-toggle {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    top: 8px;
    right: 8px;
  }
}

@media (hover: none) {
  .cup:hover {
    transform: none;
  }
}

/* ============================================================
   Reaction Timer (reaction-timer.html)
   ============================================================ */

.rt-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  margin: 6px 0 14px;
}

.rt-play-area {
  position: relative;
  flex: 1;
  min-height: 280px;
  border: 4px solid #3a1f00;
  border-radius: 22px;
  background: #fff7e0;
  box-shadow: 0 6px 0 #3a1f00;
  cursor: pointer;
  font-family: inherit;
  color: #3a1f00;
  padding: 0;
  /* Reset button defaults that fight with our flex layout */
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, transform 0.08s ease;
}

.rt-play-area:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #3a1f00;
}

.rt-play-area-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
}

.rt-play-area-msg {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 900;
  color: #3a1f00;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.6);
  line-height: 1.1;
}

.rt-play-area-time {
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 900;
  color: #ff5a1f;
  text-shadow: 2px 2px 0 #ffd24a, 4px 4px 0 rgba(0, 0, 0, 0.15);
  line-height: 1;
  letter-spacing: 1px;
}

/* Result actions row that sits below the play area (not inside it).
   Shown only when state is "result" or "too_soon". */
.rt-result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.rt-result-actions .btn {
  min-width: 200px;
}

/* State: idle — orange/yellow "Tap to Start" */
.rt-play-area.is-idle {
  background: linear-gradient(135deg, #ffd24a, #ffb000);
  color: #3a1f00;
}

/* State: waiting — red/orange "Wait..." (red signals: don't click yet) */
.rt-play-area.is-waiting {
  background: linear-gradient(135deg, #ff7a3d, #d83a1a);
  color: #fff;
}

.rt-play-area.is-waiting .rt-play-area-msg {
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

/* State: ready — green "CLICK!" with a gentle pulse so the player notices */
.rt-play-area.is-ready {
  background: linear-gradient(135deg, #6dd17a, #2ec27e);
  color: #fff;
  animation: rt-ready-pulse 0.6s ease-in-out infinite alternate;
}

.rt-play-area.is-ready .rt-play-area-msg {
  color: #fff;
  text-shadow: 3px 3px 0 #1e8a5a, 6px 6px 0 rgba(0, 0, 0, 0.25);
  font-size: clamp(2.4rem, 10vw, 4rem);
}

@keyframes rt-ready-pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.02); }
}

/* State: too soon — soft red "Too soon!" */
.rt-play-area.is-too-soon {
  background: linear-gradient(135deg, #ff9a6b, #d83a1a);
  color: #fff;
}

.rt-play-area.is-too-soon .rt-play-area-msg {
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

/* State: result — same orange as idle, but with the time + actions visible */
.rt-play-area.is-result {
  background: linear-gradient(135deg, #fff4c2, #ffd24a);
}

/* Rating line shown under the time during the result state.
   Distinct from the time number (smaller, brown) so it doesn't compete. */
.rt-play-area-rating {
  font-size: clamp(0.95rem, 3.2vw, 1.3rem);
  font-weight: 800;
  color: #3a1f00;
  background: #fff7e0;
  border: 2px solid #3a1f00;
  border-radius: 999px;
  padding: 4px 14px;
  box-shadow: 0 2px 0 #3a1f00;
  line-height: 1.1;
}

/* Stats row (Best / Last / Tries) */
.rt-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rt-stat-item {
  background: #fff;
  border: 3px solid #ff5a1f;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: 0 4px 0 #c44a00;
}

.rt-stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b34a00;
  font-weight: 700;
}

.rt-stat-value {
  display: block;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 800;
  color: #ff5a1f;
  line-height: 1.1;
  margin-top: 2px;
}

/* "Try Reaction Timer ⚡" link shown in the Coffee Rush footer */
.cr-more-games {
  display: inline-block;
  margin-top: 8px;
  background: #fff7e0;
  color: #b34a00;
  font-weight: 800;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid #3a1f00;
  box-shadow: 0 3px 0 #3a1f00;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.cr-more-games:hover {
  background: #fff;
}

.cr-more-games:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a1f00;
}

/* Mobile tweaks for Reaction Timer */
@media (max-width: 480px) {
  .rt-play-area {
    min-height: 320px;
  }
  .rt-result-actions .btn {
    min-width: 160px;
    padding: 10px 16px;
    font-size: 0.95rem;
  }
  .rt-stat-item {
    padding: 8px 6px;
  }
}

/* ============================================================
   CodeCup Arcade homepage (index.html)
   ============================================================ */

.arcade-main {
  display: flex;
  flex: 1;
  margin: 6px 0 14px;
}

.arcade-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0;
  margin: 0;
  width: 100%;
  align-content: start;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 4px solid #ff5a1f;
  border-radius: 22px;
  padding: 18px 14px;
  text-align: center;
  box-shadow: 0 8px 0 #c44a00;
}

.game-card-emoji {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.1));
}

.game-card-name {
  font-size: clamp(1.1rem, 3.5vw, 1.4rem);
  font-weight: 900;
  color: #ff5a1f;
  text-shadow: 2px 2px 0 #ffd24a;
  line-height: 1.1;
  margin: 0;
}

.game-card-desc {
  color: #3a1f00;
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  flex: 1;
}

.game-card .btn {
  margin-top: 4px;
  width: 100%;
  max-width: 220px;
  /* .btn is a <button> or <a>; either way it should not stretch to the
     full card width, but it should be the full button-target width. */
}

.game-card .btn:disabled,
.game-card .btn[disabled] {
  background: #e6d6b0;
  color: #8a6b3a;
  box-shadow: 0 4px 0 #b34a00;
  cursor: not-allowed;
  opacity: 0.85;
}

.game-card .btn:disabled:active {
  transform: none;
  box-shadow: 0 4px 0 #b34a00;
}

/* "← Back to Arcade" pill used in the per-game footers. Sits next to
   the existing "Try Reaction Timer" / "Reset Best" pills. */
.arcade-back-line {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.arcade-back-pill {
  display: inline-block;
  background: #fff7e0;
  color: #b34a00;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #3a1f00;
  box-shadow: 0 3px 0 #3a1f00;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.arcade-back-pill:hover {
  background: #fff;
}

.arcade-back-pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a1f00;
}

/* Mobile tweaks for the arcade homepage */
@media (max-width: 480px) {
  .arcade-grid {
    grid-template-columns: 1fr;
  }
  .game-card {
    padding: 14px 12px;
  }
  .game-card-emoji {
    font-size: 2.2rem;
  }
}

/* ============================================================
   Memory Match (memory-match.html)
   ============================================================ */

.mm-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  margin: 6px 0 14px;
}

.mm-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mm-stat-item {
  background: #fff;
  border: 3px solid #ff5a1f;
  border-radius: 14px;
  padding: 8px 6px;
  text-align: center;
  box-shadow: 0 4px 0 #c44a00;
}

.mm-stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #b34a00;
  font-weight: 700;
}

.mm-stat-value {
  display: block;
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  font-weight: 800;
  color: #ff5a1f;
  line-height: 1.1;
  margin-top: 2px;
}

.mm-new-game-row {
  display: flex;
  justify-content: center;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  perspective: 1000px;
}

.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 3px solid #3a1f00;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transform-style: preserve-3d;
  transition: transform 0.4s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 0 #3a1f00;
}

.memory-card:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 2px 0 #3a1f00;
}

.memory-card:disabled {
  cursor: default;
}

.memory-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.memory-card-back {
  background: linear-gradient(135deg, #fff7e0, #ffd24a);
  color: #3a1f00;
  font-size: clamp(1.4rem, 4.5vw, 2.2rem);
  font-weight: 900;
}

.memory-card-front {
  background: #fff;
  color: #3a1f00;
  font-size: clamp(1.8rem, 7vw, 3rem);
  transform: rotateY(180deg);
  line-height: 1;
}

.memory-card.is-flipped {
  transform: rotateY(180deg);
  border-color: #ff5a1f;
  box-shadow: 0 4px 0 #c44a00;
}

.memory-card.is-flipped:active {
  transform: rotateY(180deg) translateY(2px) scale(0.98);
}

.memory-card.is-matched {
  border-color: #1e8a5a;
  background: #fff;
  box-shadow: 0 4px 0 #1e8a5a;
  /* Locked in the face-up orientation — disabled buttons can't be clicked
     again, so we just want them to stay face-up. The rotateY(180) is
     already set by .is-flipped, so no extra transform needed. */
}

.memory-card.is-matched .memory-card-front {
  background: linear-gradient(135deg, #fff4c2, #ffd24a);
}

/* Win screen — appears in-flow below the grid when the player matches
   all 8 pairs. Same card language as the other game-over cards. */
.mm-win-screen {
  margin-top: 4px;
}

.mm-win-card {
  background: #fff;
  border: 4px solid #ff5a1f;
  border-radius: 22px;
  padding: 22px 18px;
  box-shadow: 0 8px 0 #c44a00;
  text-align: center;
  animation: card-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mm-win-title {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  color: #ff5a1f;
  margin-bottom: 6px;
  text-shadow: 2px 2px 0 #ffd24a;
}

.mm-win-subtitle {
  color: #3a1f00;
  font-weight: 700;
  margin-bottom: 14px;
}

.mm-win-stats {
  background: #fff7e0;
  border: 2px dashed #b34a00;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.mm-win-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mm-win-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b34a00;
  font-weight: 800;
}

.mm-win-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mm-win-value {
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-weight: 900;
  color: #ff5a1f;
}

.mm-win-sep {
  font-size: 0.85rem;
  color: #8a6b3a;
  font-weight: 600;
}

.mm-new-best-badge {
  display: inline-block;
  background: linear-gradient(135deg, #2ec27e, #1e8a5a);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 2px 0 #1e8a5a;
  margin-left: 4px;
}

.mm-result-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.mm-result-row .btn {
  width: 100%;
  max-width: 320px;
}

/* Mobile tweaks for Memory Match */
@media (max-width: 480px) {
  .mm-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .memory-grid {
    gap: 8px;
  }
  .memory-card {
    border-width: 2px;
    box-shadow: 0 3px 0 #3a1f00;
  }
  .mm-win-stats {
    padding: 10px 12px;
  }
}

/* ============================================================
   Math Rush (math-rush.html)
   ============================================================ */

.math-play-area {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  background: #fff7e0;
  border: 4px dashed #ff5a1f;
  border-radius: 22px;
  padding: 16px;
  margin-bottom: 14px;
}

.math-question {
  background: #fff;
  border: 4px solid #ff5a1f;
  border-radius: 18px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 6px 0 #c44a00;
}

.math-question-text {
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 900;
  color: #ff5a1f;
  text-shadow: 2px 2px 0 #ffd24a, 4px 4px 0 rgba(0, 0, 0, 0.15);
  letter-spacing: 1px;
  line-height: 1.1;
  word-spacing: 6px;
}

.math-answer-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
}

.math-answer-input {
  flex: 1;
  font-family: inherit;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 800;
  text-align: center;
  color: #3a1f00;
  background: #fff;
  border: 3px solid #3a1f00;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 4px 0 #3a1f00;
  outline: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.15s ease;
  -moz-appearance: textfield;
  appearance: textfield;
}

.math-answer-input::-webkit-outer-spin-button,
.math-answer-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.math-answer-input:focus {
  border-color: #ff5a1f;
  box-shadow: 0 4px 0 #c44a00;
}

.math-answer-row .btn {
  min-width: 110px;
  font-size: 1rem;
  padding: 10px 18px;
}

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

.keypad-btn {
  background: #fff;
  color: #3a1f00;
  font-family: inherit;
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  font-weight: 900;
  padding: 14px 0;
  border: 3px solid #3a1f00;
  border-radius: 14px;
  box-shadow: 0 4px 0 #3a1f00;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.keypad-btn:hover {
  background: #fff7e0;
}

.keypad-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #3a1f00;
}

.keypad-btn.is-backspace {
  background: #fff7e0;
  color: #b34a00;
  font-size: clamp(1rem, 4vw, 1.3rem);
}

.keypad-btn.is-submit {
  background: #2ec27e;
  color: #fff;
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  box-shadow: 0 4px 0 #1e8a5a;
}

.keypad-btn.is-submit:hover {
  background: #36d18a;
}

.keypad-btn.is-submit:active {
  box-shadow: 0 2px 0 #1e8a5a;
}

.math-feedback {
  text-align: center;
  min-height: 1.6em;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

.math-feedback.is-correct {
  color: #2ec27e;
  text-shadow: 1px 1px 0 #1e8a5a;
}

.math-feedback.is-wrong {
  color: #d83a1a;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

/* Result row on the game-over card: shows correct/wrong counts
   and the "New best!" badge. */
.math-result-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.math-result-pill {
  display: inline-block;
  background: #fff7e0;
  border: 2px solid #b34a00;
  border-radius: 999px;
  padding: 5px 12px;
  color: #3a1f00;
  font-weight: 800;
  font-size: 0.9rem;
}

.math-new-best-badge {
  display: inline-block;
  background: linear-gradient(135deg, #2ec27e, #1e8a5a);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 0 #1e8a5a;
}

/* Mobile tweaks for Math Rush */
@media (max-width: 480px) {
  .math-play-area {
    padding: 12px;
  }
  .math-question {
    padding: 16px 12px;
  }
  .math-answer-row .btn {
    min-width: 90px;
    padding: 10px 12px;
    font-size: 0.95rem;
  }
  .keypad-btn {
    padding: 12px 0;
  }
}
