/* ===================
   Logic Font Definitions
   =================== */
@font-face {
  font-display: swap;
  font-family: "Logic Monospace";
  font-style: normal;
  font-weight: 400;
  src: url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-Medium.woff2") format("woff2"),
    url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-Medium.woff") format("woff");
}

@font-face {
  font-display: swap;
  font-family: "Logic Monospace";
  font-style: normal;
  font-weight: 300;
  src: url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-Regular.woff2") format("woff2"),
    url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-Regular.woff") format("woff");
}

@font-face {
  font-display: swap;
  font-family: "Logic Monospace";
  font-style: italic;
  font-weight: 300;
  src: url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-RegularItalic.woff2") format("woff2"),
    url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-RegularItalic.woff") format("woff");
}

@font-face {
  font-display: swap;
  font-family: "Logic Monospace";
  font-style: italic;
  font-weight: 400;
  src: url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-MediumItalic.woff2") format("woff2"),
    url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-MediumItalic.woff") format("woff");
}

@font-face {
  font-display: swap;
  font-family: "Logic Monospace";
  font-style: normal;
  font-weight: 700;
  src: url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-Bold.woff2") format("woff2"),
    url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-Bold.woff") format("woff");
}

@font-face {
  font-display: swap;
  font-family: "Logic Monospace";
  font-style: italic;
  font-weight: 700;
  src: url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-BoldItalic.woff2") format("woff2"),
    url("https://www.theatlantic.com/packages/fonts/logic/LogicMonospace-BoldItalic.woff") format("woff");
}

/* ===================
   Root Variables and Resets
   =================== */
   :root {
    --main-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --mono-font: "Logic Monospace", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --highlight-color: #fefcbf;
  }

  /* Custom monospace font for solid underscores */
  @font-face {
    font-family: 'CustomMono';
    /* Use ui-monospace for every character except underscore */
    src: local("ui-monospace");
    /* All Unicode except underscore (U+005F) */
    unicode-range: U+0000-005E, U+0060-10FFFF;
  }

  @font-face {
    font-family: 'CustomMono';
    /* Use Menlo for underscore only */
    src: local("Menlo");
    unicode-range: U+005F;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }
  
  /* ===================
     Container Structure
     =================== */
  .puzzle-container {
    width: 100%;
    margin: 0 auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 0;
    display: flex;
    flex-direction: column;
    font-style: normal;
    font-weight: 300;
  }
  
  @media (min-width: 640px) {
    .puzzle-container {
      max-width: 42rem;
    }
  }
  
  /* ===================
     Header Styles
     =================== */
  /* Header Base Styles */
  .puzzle-header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    box-sizing: border-box;
    padding: 0.6rem;
    border-radius: 0.5rem;
    position: relative; /* Desktop default */
    text-align: center;
    z-index: 10;
  }

  /* Mobile-specific header styles */
  @media (max-width: 640px) {
    .puzzle-header {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 1000;
      padding: max(0.4rem, env(safe-area-inset-top));
      max-height: 100px;
      transition: max-height 0.3s ease;
    }
  }

  .collapsed {
    display: none;
    max-height: 0;
  }

  /* Header title */
  .puzzle-header h1 {
    margin: 0 0 0.5rem 0;
    text-align: center;
    font-size: clamp(1rem, 6vw, 2rem);
    cursor: pointer;
    font-family: var(--main-font);
    font-variant: small-caps;
    color: #1a202c;
    font-weight: 600;
  }

  .difficulty-indicator {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 0.8em;
  }

  .difficulty-indicator:focus {
    outline: none;
  }

  .announcement-modal.difficulty-modal {
    width: min(90vw, 24rem);
    padding: 2rem;
    text-align: center;
  }

  .announcement-modal.difficulty-modal .announcement-modal-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0rem;
    font-family: var(--main-font);
    display: block;
    border-bottom: none;
  }

  .announcement-modal.difficulty-modal .difficulty-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0rem;
    margin-bottom: 1.5rem;
  }

  .announcement-modal.difficulty-modal .difficulty-indicator-display {
    font-size: clamp(3rem, 7vw, 3.75rem);
  }

  .announcement-modal.difficulty-modal .difficulty-label {
    font-size: 1.4rem;
    font-weight: 600;
    color: #111827;
    font-family: var(--main-font);
  }

  .announcement-modal.difficulty-modal .difficulty-detail {
    font-size: 1rem;
    color: #4b5563;
    text-align: center;
    font-family: var(--main-font);
    padding-top: 1rem;
  }

  .announcement-modal.difficulty-modal .announcement-modal-button {
    margin: 0 auto;
    width: auto;
    padding: 0.75rem 2.5rem;
  }

  @media (max-width: 640px) {
    .puzzle-header h1 {
      margin: 0;
      font-size: clamp(1.8rem, 7vw, 2.8rem);
    }
  }

  /* Help button */
  .help-icon {
    background: none;
    border: 2px solid #333;
    border-radius: 50%;
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: #333;
  }
  
  .puzzle-header .help-button {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 200;
    background: none;
    border: 2px solid #333;
    border-radius: 50%;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    color: #333;
  }

  @media (max-width: 640px) {
    .puzzle-header .help-button {
      right: 10px;
    }

    /* Force solid background on mobile for tutorial prompt */
    .help-button.new-player-highlight::after {
      background: rgba(51, 51, 51, 1) !important;
    }

    .help-button.new-player-highlight::before {
      border-bottom-color: rgba(51, 51, 51, 1) !important;
    }
  }

  /* Exit button for tutorial */
  .puzzle-header .exit-button {
    position: absolute;
    top: 10px;
    right: 20px;
    background: none;
    border: 2px solid #333;
    border-radius: 50%;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    color: #333;
    transition: all 0.2s ease;
  }

  .puzzle-header .exit-button:hover {
    background-color: #333;
    color: white;
  }

  .puzzle-header .exit-button:active {
    transform: scale(0.95);
  }

  @media (max-width: 640px) {
    .puzzle-header .exit-button {
      right: 10px;
    }
  }

  /* Text bubble for help button */
.help-button.new-player-highlight::after {
  content: "confused? try the tutorial";
  position: absolute;
  top: 42px;
  right: -10px;
  background: rgba(51, 51, 51, 1) !important;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: normal;
  white-space: nowrap;
  z-index: 210;
  box-shadow: 0 2px 3px rgba(0,0,0,0.2);
  /*animation: fade-in-out 3s infinite;*/
}

/* Triangle pointer for the bubble */
.help-button.new-player-highlight::before {
  content: "";
  position: absolute;
  top: 35px;
  right: 10px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid rgba(51, 51, 51, 1);
  z-index: 210;
  /*animation: fade-in-out 3s infinite;*/

}

/* Animation for the bubble to fade in and out */
@keyframes fade-in-out {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Keep the pulsing animation for the button itself */
.help-button.new-player-highlight {
  border-color: rgb(0, 0, 0);
  color: rgb(0, 0, 0);
  animation: pulse 1s infinite;
}

  /* Optional: Pulse animation to draw attention */
  @keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.10); }
    100% { transform: scale(1); }
  }

  /* Help button */
  .puzzle-header .info-button {
    position: absolute;
    top: 10px;
    left: 20px;
    background: none;
    border: 2px solid #333;
    border-radius: 50%;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    font-family: menlo;
    color: #333;
  }

  /* Style for the unseen info button */
  .info-button.unseen-info {
    border-color: #000000; /* Red border */
    color: #ef4444; /* Red text */
    /*animation: pulse 1s infinite;  Optional: add a subtle pulse animation */
  }

  /* Optional: Pulse animation to draw attention */
  @keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.10); }
    100% { transform: scale(1); }
  }

  @media (max-width: 640px) {
    .puzzle-header .info-button {
      left: 10px;
    }
  }

  /* Navigation container */
  .puzzle-header .nav-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
  }

  /* Navigation buttons */
  .puzzle-header .nav-button {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.5rem;
    color: #333;
  }

  .puzzle-header .nav-button:disabled {
    opacity: 0.3;
    cursor: default;
  }

  /* Puzzle date */
  .puzzle-header .puzzle-date {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    font-family: var(--main-font);
    font-variant: small-caps;
    color: #1a202c;
  }
  
  /* ===================
     Main Content Area
     =================== */
  /* New rules for loading state */
  
  .loading {
    text-align: center;
    padding: 2rem;
  }

  .puzzle-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0rem;
    background-color: #F5F5F5;
    width: 100%;
  }

    /* ===================
      Puzzle Solved! Message
      =================== */
  
    .solved-message {
      display: none;
      font-size: 2rem;
      padding: 24px 0 40px 0;
      text-align: center;
      font-family: var(--mono-font);
    }
  
    .puzzle-content.completed .solved-message {
      display: block;
    }
  
    @media (max-width: 640px) {
      .solved-message {
        font-size: 1.5rem;
        padding: 24px 0 40px 0;
      }
    }
  /* ===================
    Tutorial Overlay
    =================== */
.tutorial-overlay {
  display: none;
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
}

  .tutorial-overlay--visible {
    display: flex !important;
  }
  
  /* ===================
     Puzzle Display
     =================== */
  .puzzle-display {
    width: 100%;
    min-height: 40vh;
    max-height: 60vh;
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    font-family: var(--mono-font);
    font-size: 20px;
    line-height: 1.5;
    overflow-y: auto;
    word-break: keep-all;
    overflow-wrap: break-word;
    hyphens: none;
    font-variant-numeric: normal !important;
    font-variant-ligatures: none !important;
    font-feature-settings: "frac" 0, "afrc" 0 !important;
    -webkit-font-feature-settings: "frac" 0, "afrc" 0 !important;
    transition: all 0.3s ease;
    margin: 0rem 0rem 1rem 0rem
  }
  
  .puzzle-display.completed {
    min-height: auto;
    max-height: none;
    height: auto;
  }

  .blank-line {
    display: inline-block;
    border-bottom: .15rem solid currentColor;
    line-height: 1;
    position: relative;
    top: .2rem; /* Move line down slightly */
    padding: 0 2px;
    margin: 0 1px;
  }

  @media (max-width: 640px) {
    .blank-line {
      border-bottom: .1rem solid currentColor;
    }
  }
  
  /* ===================
     Active Clue & Mark Styles
     =================== */
  .active-clue {
    background-color: #D6E0FF;
    border-radius: 3px;
    padding: 2px 4px;
    margin: -2px 0;
    transition: background-color 0.3s ease;
    cursor: pointer;
    color: black;
    font-weight: 500;
  }
  
  .active-clue:hover {
    background-color: #B8C8FF;
  }
  
  mark.solved {
    background-color: #99EBDD;
    border-radius: 3px;
    padding: 2px 0;
    margin: -2px 0;
  }
  
  mark {
    background-color: transparent;
    color: inherit;
  }
  
  /* ===================
     Input Styles
     =================== */
  .input-container {
    width: 100%;
    margin: 10px 0 0 0;
    position: relative;
    font-family: var(--mono-font);
  }
  
  .answer-input {
    width: 100%;
    padding: 16px;
    height: 60px;
    font-size: 16px !important;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 0px;
    box-sizing: border-box;
    font-family: var(--mono-font);
  }
  
  /* ===================
     Message Styles
     =================== */
  .message {
    padding: 0.5rem;
    margin: 0.5rem 0;
    border-radius: 0.375rem;
    text-align: center;
    font-family: var(--mono-font);
    display: none;
  }
  
  .message.success {
    background-color: #99EBDD;
    color: #1a202c;
    overflow-wrap: anywhere;
    font-size: 1.2rem;
    display: block;
    padding: 20px;
    line-height: 2rem;
    text-align: center;
  }
  
  .message.error {
    background-color: #F54900;
    color: #fff;
    overflow-wrap: anywhere;
    font-size: 1.2rem;
    display: block;
    padding: 20px;
    line-height: 2rem;
  }
  
  .message.warning {
    background-color: #FDE68A;
    color: #000;
    overflow-wrap: anywhere;
    font-size: 1.2rem;
    display: block;
    padding: 20px;
    line-height: 2rem;
    text-align: center;
  }
  

  .message.success .completion-link {
    color: #2563eb;
    text-decoration: underline;
  }

  
  /* ===================
     Completion Message
     =================== */
  .message.success.completion-message {
    margin: 0rem 0rem 0rem 0rem;
    border-radius: 0.375rem;
    font-family: var(--mono-font);
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: left;
    background-color: transparent;
    padding: 24px 0 0;
  }

  .message.success.completion-message a{
    color: #000;
    text-decoration: underline;
  }
  
  /* ===================
     Solved Expressions
     =================== */
  .solved-expressions {
    margin-top: 0rem;
  }
  
  .solved-expressions h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 0.75rem;
    font-family: var(--mono-font);
    color: #1a202c;
  }
  
  .expression-item {
    background: white;
    padding: 24px;
    border-radius: 0.375rem;
    margin-bottom: 16px;
    font-size: 18px;
    font-family: var(--mono-font);
    line-height: 1.5;
  }
  
  .expression-item .solution {
    color: black;
    background-color: #99EBDD;
  }
  
  /* ===================
     Email Form Styles
     =================== */

  .email-signup-container {
    margin: 1rem 0.5rem 0.5rem 0.5rem;
  }

  .email-signup-form label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-align: center;
    font-family: var(--mono-font);
    font-size: 1.1rem;
  }

  .email-signup-form label span
  {
    background-color: rgba(255, 255, 0, 0.2); padding: 0.2rem 0.4rem;
  }

  .email-input-container {
    display: flex; 
    gap: 0.5rem;
  }

  .email-signup-form input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 0.375rem;
    font-size: 16px;
    gap: 0.5rem
  }

  .email-signup-form button {
    padding: 0.5rem 1rem;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
  }
  .email-signup-message {
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    text-align: center;
    font-family: var(--mono-font);
  }

  .email-signup-message .success {
    padding: 1rem; 
    background-color: #ecfdf5; 
    border: 1px solid #6ee7b7; 
    border-radius: 0.375rem; 
    color: #065f46;
  }
  
  .email-signup-message .error {
    padding: 1rem; 
    background-color: #fef2f2; 
    border: 1px solid #fca5a5; 
    border-radius: 0.375rem; 
    color: #991b1b;
  }
  
  /* ===================
     Stats & Completion
     =================== */
  .stats-content {
    margin-top: 0rem;
  }
  
  .stat-items {
    margin: 16px 0;
    background-color: white;
    border-radius: 0.375rem;
    display: flex;
    padding: 24px;
    font-family: var(--mono-font);
  }

  .stat-items.horizontal {
    justify-content: space-between;
    align-items: flex-start;
    align-self: stretch;
    gap: 0.5rem;
  }

  .stat-items.vertical {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .stat-item {
    font-size: 1rem;
    line-height: 1.5;
  }

  .stat-items.vertical .stat-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  
  /* ===================
     Rank Display
     =================== */
.rank-display {
  --angle: 0deg;
  font-family: var(--mono-font);
  position: relative;
  overflow: hidden;
  padding: 1rem;
  text-align: center;
  font-size: 1.2em;
  font-weight: 500;
  margin: 0rem 0rem 1rem 0rem;

  /* Remove border-image to let border-radius work */
  border: 5px solid transparent;
  border-radius: 12px; /* bump up radius for visibility */
  
  /* Use a pseudo-element for gradient border */
  background: 
    linear-gradient(white, white) padding-box, 
    conic-gradient(from var(--angle), red, yellow, lime, aqua, blue, magenta, red) border-box;

  animation: rotate 5s linear infinite;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  cursor: pointer;
}

  .rank-display .next-rank {
    font-size: 0.8em;
    font-weight: normal;
  }

                @keyframes rotate {
                  to {
                    --angle: 360deg;
                  }
                }
        
                @property --angle {
                  syntax: '<angle>';
                  initial-value: 0deg;
                  inherits: false;
  }
  
  /* Rank gradients */
.rank-display[data-rank="Tourist"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #f0fdf4, #6ee7b7, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Commuter"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #FFEFD6, #FF7E47, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Resident"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #f8fafc, #cbd5e1, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Council Member"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #fafaf9, #d6d3d1, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Chief of Police"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #f0f9ff, #93c5fd, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Mayor"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #fff1f2, #fda4af, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Power Broker"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #fefce8, #92400e, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Kingmaker"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #fffbeb, #fcd34d, white) border-box;
  border-color: transparent;
}

.rank-display[data-rank="Puppet Master"] {
  background:
    linear-gradient(white, white) padding-box,
    conic-gradient(from var(--angle), white, #faf5ff, #d8b4fe, white) border-box;
  border-color: transparent;
}
        
                .rank-display .rank-button-bar {
                  display: flex;
                  gap: 12px;
                  justify-content: center;
                  align-items: center;
                  padding-top: 24px;
                }
        
                .rank-button-bar a {
                  color: inherit;
                  text-decoration: none;
                }
        
                .rank-display .rank-button {
                  display: flex;
                  height: 42px;
                  min-width: 168px;
                  max-width: 232px;
                  padding: 14px 12px;
                  justify-content: center;
                  align-items: center;
                  border-radius: 4px;
                  border: 2px solid #000;
                  background: #000;
                  color: white;
                  font-size: 14px;
                  font-family: var(--mono-font);
                  cursor: pointer;
                }
                .rank-display .rank-button:active {
                  transform: scale(0.95);
  }

                .rank-display .rank-button.inverse {
                  color: black;
                  background-color: white;
  }

.rank-display .share-message {
  display: none;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #4a5568;
  text-align: center;
}
  
  /* ===================
     Mobile Styles
     =================== */
  @media (max-width: 640px) {
    body {
      margin: 0;
      padding: 0;
      height: 100vh;
      font-size: 14px;
      overflow: hidden;
    }
  
    .message.success {
      background-color: #99EBDD;
      color: #1a202c;
      overflow-wrap: anywhere;
      font-size: 1rem;
      display: block;
      line-height: 1.4rem;
      padding: 10px; /* This padding will now correctly apply */
      line-height: 1.4rem;
      margin-top: 0.2rem;
    }
  
    .message.error {
      background-color: #F54900;
      color: #fff;
      overflow-wrap: anywhere;
      font-size: 1rem;
      display: block;
      line-height: 1.4rem;
      padding: 10px; /* This padding will now correctly apply */
      line-height: 1.4rem;
      margin-top: 0.2rem;
    }
    
    .message.warning {
      background-color: #FDE68A;
      color: #000;
      overflow-wrap: anywhere;
      font-size: 1rem;
      display: block;
      text-align: center;
      padding: 10px;
      line-height: 1.4rem;
      margin-top: 0.2rem;
    }
  
    /* Mobile container setup */
    .puzzle-container {
      height: 100vh;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      flex-direction: column;
    }
  
    /* Mobile content area */
    .puzzle-content {
      position: absolute;
      top: 95px;
      left: 0;
      right: 0;
      bottom: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding: 0;
      gap: 0rem;
      transition: top 0.3s ease;
    }

    .header-collapsed {
      top: 0;
    }
    
    @font-face {
      font-family: 'CustomMono';
      /* Use ui-monospace for every character except underscore */
      src: local("ui-monospace");
      /* All Unicode except underscore (U+005F) */
      unicode-range: U+0000-005E, U+0060-10FFFF;
    }
    
    @font-face {
      font-family: 'CustomMono';
      /* Use Menlo for underscore only */
      src: local("Menlo");
      unicode-range: U+005F;
    }

    .puzzle-display {
      height: auto;
      padding: 0.5rem 1rem 1rem 1rem;
      margin: 0rem 0rem 1rem 0rem;
      font-size: 19px;
      background: white;
      padding-bottom: 200px;
      font-family: var(--mono-font);
      font-variant-numeric: normal !important;
      font-variant-ligatures: none !important;
      font-feature-settings: "frac" 0, "afrc" 0 !important;
      -webkit-font-feature-settings: "frac" 0, "afrc" 0 !important;
    }
  
    .puzzle-container.completed .puzzle-display.completed {
      padding-bottom: 1rem !important;
    }
    
    /* Mobile input container */
    .input-container {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: white;
      z-index: 10;
      width: 100%;
      border-top: 1px solid #e2e8f0;
      box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
      padding: 0.5rem calc(0.5rem + env(safe-area-inset-left)) calc(0.5rem + env(safe-area-inset-bottom)) calc(0.5rem + env(safe-area-inset-right));
      box-sizing: border-box;
      background-color: #D5D5D5;
    }
  
    .custom-input {
      border: 1px solid #e2e8f0;
      padding: 0.63rem;
      border-radius: 6px;
      margin-bottom: 0.125rem;
      font-family: var(--mono-font);
      font-size: 1.25rem;
      min-height: 2.4rem;
      background: white;
      width: 100%;
      color: #000;
    }

    .placeholder {
      color: black;
    }
  
    /* Mobile keyboard */
    .custom-keyboard {
      width: 100%;
      padding: .25rem 0 0 0;
      box-sizing: border-box;
      background-color: #D5D5D5;
      touch-action: none;
    }
  
    .keyboard-row {
      display: grid;
      grid-template-columns: repeat(10, 1fr);
      gap: 0.02rem;
      margin-bottom: 0.125rem;
      justify-content: center;
      width: 100%;
    }
  
    .keyboard-key {
      font-family: var(--mono-font);
      height: 3.3rem;
      min-height: 2.38rem;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0.2rem;
      margin: 0.1rem 0.15rem 0.1rem 0.15rem;
      cursor: pointer;
      color: black;
      background-color: white;
      box-sizing: border-box;
      touch-action: manipulation;
      text-align: center;
      font-size: 1.5rem;
      font-weight: 400;
      border: 1px solid white;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
      -webkit-appearance: none !important;
      appearance: none !important;
      border-radius: 4px !important;
      outline: none !important;
      -webkit-tap-highlight-color: transparent !important;
      transition: background-color 0.1s ease-out,
                  transform 0.1s ease-out;
      -webkit-user-select: none;
      user-select: none;
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
      text-transform: uppercase;
    }
  
    .keyboard-key:active {
      background-color: #94a3b8;
      transform: translateY(2px);
    }
  
    /* Hide desktop elements */
    .bottom-controls,
    .reset-button,
    .solved-expressions,
    .keystroke-stats,
    .share-button.copy {
      display: none;
    }
  
    /* Mobile completion state */
    .puzzle-container.completed .puzzle-content {
      position: static;
      height: auto;
      overflow: visible;
      /*margin-top: 95px;*/
      padding: 1rem; 
    }
  
    .puzzle-container.completed {
      position: static;
      height: auto;
      min-height: 100vh;
      overflow-y: auto;
    }
  
    .puzzle-display.completed .input-container {
      display: none;
    }
  
    .puzzle-container.completed .solved-expressions,
    .puzzle-container.completed .keystroke-stats {
      display: block;
    }

    .rank-display {
      margin: 0rem 0rem 0rem 0rem;
    }
    

  }
  
  /* ===================
     iOS-specific Styles
     =================== */
  @supports (-webkit-touch-callout: none) {
    .keyboard-key:active {
      background-color: #94a3b8 !important;
      transform: translateY(2px) !important;
    }
  }

  /* ===================
     Score Bar
     =================== */

  .score-bar {
    margin: 16px 0;
    text-align: center;
    font-size: 1.1rem;
    font-family: var(--mono-font), monospace;
    padding: 1rem;
    border-radius: 0.5rem;
    background-color: white;
  }

  .score-value {
    font-weight: bold;
    font-family: var(--mono-font), monospace;
    margin-bottom: 0rem;
    font-size: 24px;
    margin-bottom: 16px;
  }

  .score-bar-footer {
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 24px;
  }

  .progress-bar {
    font-size: 1.5rem;
    letter-spacing: 0.1rem;
    line-height: 1.5;
  }

  .average-progress-bar {
    font-size: 1.2rem;
    letter-spacing: 0.1rem;
    line-height: 1.5;
    text-align: center;
    margin-top: 2px;
    opacity: 0.5;
  }

  /* Mobile adjustments */
  @media (max-width: 640px) {
    .score-bar {
      margin: 1rem 0;
      font-size: 1rem;
      padding: 0.75rem;
    }
    
    .progress-bar {
      font-size: 1.2rem;
    }

    .average-progress-bar {
      font-size: 0.9rem; /* 75% of 1.2rem */
    }
  }

  /* Submit button and input wrapper */
  .input-submit-wrapper {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    padding-left: 4px;
    padding-right: 4px;
  }

  .submit-answer {
    padding: 0 1.5rem;
    height: 60px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    font-family: var(--mono-font);
    white-space: nowrap;
    font-size: 1rem;
  }

  .submit-answer:hover {
    background-color: #1d4ed8;
  }

  .submit-answer:active {
    background-color: #1e40af;
    transform: scale(0.98);
  }

  .mobile-submit-button {
    color: #000 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    background-color: #D5D5D5 !important;
    font-family: var(--mono-font) !important;
  }

/* Date Picker Styles */
.puzzle-date {
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s ease;
  padding: 4px;  /* Larger tap target */
  border-radius: 4px;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0); /* Remove default mobile tap highlight */
  touch-action: manipulation; /* Optimize for touch */
}

.puzzle-date:hover {
  color: #4299e1;
  background-color: rgba(66, 153, 225, 0.1);
}

.puzzle-date:active {
  transform: scale(0.98);
}

.puzzle-date::after {
  content: "\23F7"; /* dropdown arrow maybe */
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.8em;
  opacity: 0.7;
}

/* Visible hint on mobile */
@media (max-width: 640px) {
  .puzzle-date {
    padding: 5px 8px;
    border: none !important; /* Explicitly remove any border */
  }
  
  .puzzle-date::after {
    font-size: 1em;
    margin-left: 8px;
  }
}

.date-picker-container {
  font-family: var(--main-font);
  border-radius: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background-color: white;
  animation: fadeIn 0.2s ease;
  box-sizing: border-box;
  overflow: hidden; /* Ensure nothing bleeds outside the container */
  padding: 1rem !important; /* Force padding */
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px) translateX(-50%); }
  to { opacity: 1; transform: translateY(0) translateX(-50%); }
}

.month-nav {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.month-nav:hover {
  background-color: #f0f0f0;
}

.weekdays {
  font-size: 0.85rem;
  color: #4a5568;
  padding-bottom: 0.5rem;
}

.calendar-grid {
  font-size: 0.95rem;
}

.date-cell {
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  user-select: none;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-cell.has-puzzle:hover:not([disabled="true"]) {
  transform: translateY(-2px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.date-cell.has-puzzle:active:not([disabled="true"]) {
  transform: translateY(0);
}

.date-cell.has-puzzle[data-status="complete"] {
  position: relative;
}

.date-cell.has-puzzle[data-status="complete"]::after {
  content: "\2713";
  position: absolute;
  top: 0;
  right: 2px;
  font-size: 8px;
  color: #22543d;
}

.date-cell.has-puzzle[data-status="started"] {
  position: relative;
}

.date-cell.has-puzzle[data-status="started"]::after {
  content: "\2022\2022\2022";
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  color: #744210;
}

.empty-day {
  aspect-ratio: 1;
}

/* Mobile styles */
/* Fix for the date picker right column padding issue on mobile */

/* Balanced fix for date picker columns on mobile */

/* Robust fix for date picker edge issues on mobile */

@media (max-width: 640px) {
  /* Force container to be smaller than viewport width and centered */
  .date-picker-container {
    width: 85vw !important; /* Reduced from 90vw to ensure space */
    max-width: 300px !important; /* Smaller max-width */
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0.75rem !important; /* Slightly reduced padding */
    box-sizing: border-box !important;
    border-radius: 0.5rem !important;
    overflow: hidden !important; /* Force content to stay within bounds */
  }
  
  /* Force grid to be contained */
  .calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 3px !important; /* Reduced gap */
    width: 100% !important; 
    max-width: 100% !important; /* Ensure it can't exceed container */
    overflow: visible !important; /* Allow cell content to be visible */
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Ensure weekday headers don't overflow */
  .weekdays {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 3px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 0 8px 0 !important; 
  }
  
  /* Make date cells slightly smaller */
  .date-cell {
    width: 100% !important;
    height: auto !important;
    min-height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.2rem 0 !important;
    font-size: 0.85rem !important; /* Slightly smaller text */
    margin: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Explicitly set column sizes */
  .calendar-grid > div, .weekdays > div {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Additional safeguard for month selector */
  .date-picker-header {
    padding: 0 !important;
    margin-bottom: 0.75rem !important;
  }
  
  .rank-button-bar {
    flex-direction: column;
  }

  .rank-button-bar .rank-button {
    width: 100%;
  }
}

/* Ensure day number (inside the span) is visually on top */
.date-cell > span {
  position: relative;
  z-index: 1;
}

.date-cell.has-puzzle[data-status="complete"]::after {
  content: "\2713";
  position: absolute;
  top: 0; /* Adjusted for better vertical alignment with small font */
  right: 2px;
  font-size: 8px; /* Keep small for subtlety */
  color: #22543d; /* Original color for non-streak complete */
  z-index: 1;
}

.date-cell.streak-member[data-status="complete"]::after {
  color: #5b21b6; /* Purple checkmark for streak complete days */
}

/* Fire emoji for ACTIVE STREAK completed days */
.date-cell.streak-member[data-status="complete"]::after {
  content: "\1F525"; /* Fire emoji Unicode: 🔥 */
  /* color: transparent; /* Not needed if using emoji directly */
  font-size: .5rem; /* Adjust size of fire emoji as needed */
  right: 2px;
}

.date-cell.has-puzzle[data-status="started"]::after {
  content: "\2022\2022\2022";
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  color: #744210;
  z-index: 1;
}

/* iOS Toggle Switch */
.toggle-container {
  margin: 1em 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-labels {
  display: flex;
  flex-direction: column;
}

.toggle-title {
  font-weight: 500;
  margin-bottom: 0.3em;
}

.toggle-description {
  font-size: 0.8em;
  color: #666;
  line-height: 1.2;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
  margin-left: 12px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
  background-color: #2563eb;
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* Mode labels */
.mode-indicator {
  margin-top: 0.8em;
  font-size: 0.9em;
  color: #555;
  text-align: center;
}

.mode-name {
  font-weight: 600;
  color: #2563eb;
}

/* Modal Styles */
.announcement-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.announcement-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.announcement-modal {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.announcement-modal.small {
  max-width: 328px;
}
.announcement-modal-overlay.visible .announcement-modal {
  transform: translateY(0);
}

.announcement-modal-title {
  font-size: 1.375rem;
    padding-bottom: 1rem;
  margin-bottom: 1rem;
  color: #1a202c;
  text-align: center;
  font-family: var(--main-font);
  display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #EFF2F7
  }
  
  .announcement-modal-x {
    all: unset;
    cursor: pointer;
}

.announcement-modal-content {
  font-size: 1.125rem;
  line-height: 1.5;
  color: #4a5568;
  margin-bottom: 1.5rem;
  font-family: var(--main-font);
  padding: 0;
  }
  
  .announcement-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
}

.announcement-modal-button {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
  font-family: var(--mono-font);
    font-size: 0.875rem;
  }
  
  .announcement-modal-button.black {
    background-color: black;
    color: white;
  }
  
  .announcement-modal-button.black:hover {
    background-color: black;
  }
  
  .announcement-modal-button.white {
    background-color: white;
    color: black;
    border: 2px solid black;
  }
  
  .announcement-modal-button.white:hover {
    background-color: white;
  }
  
  .announcement-modal-actions .announcement-modal-button {
    max-width: 232px;
}

.announcement-modal-button:hover {
  background-color: #1d4ed8;
}

.announcement-modal-button:active {
  background-color: #1e40af;
  transform: scale(0.98);
}

/* Add more space between list items */
.announcement-modal-content li {
  margin-bottom: 0.75rem;
}

/* Remove extra margin from the last list item */
.announcement-modal-content li:last-child {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .announcement-modal {
    width: 85%;
    padding: 1rem;
  }
  
  .announcement-modal-title {
    font-size: 1.25rem;
  }
  
  .announcement-modal-content {
    font-size: 0.95rem;
  }
}

/* Dark Mode */
html.bracket-city-dark-mode {
  body {
    background-color: #1e1e1e;
  }
  .puzzle-container {
    border-color: #373737;
  }
  .puzzle-header {
    background-color: #373737;
  }
  .puzzle-header h1 {
    color: white;
  }
  .puzzle-header .puzzle-date {
    color: white;
  }
  .puzzle-header .nav-button {
    color: white;
  }
  .puzzle-content {
    background-color: #2d2d2d;
  }
  .puzzle-display {
    color: white;
    background-color: #373737;
  }
  .puzzle-header .info-button, .puzzle-header .info-button.unseen-info, .puzzle-header .help-button {
    border-color: white;
    color: white;
  }
  .info-button.unseen-info {
    color: red;
  }
  .answer-input {
    background: #2d2d2d;
    color: white;
  }
  .expression-item {
    background-color: #5d5d5d;
    color: white;
  }
  .rank-display {
    color: white;
  }
  .rank-display .share-message {
    color: #f9fafb;
  }
  .rank-display[data-rank="Tourist"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #f0fdf4, #6ee7b7, white) border-box;
  }
  .rank-display[data-rank="Commuter"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #FFEFD6, #FF7E47, white) border-box;
  }
  .rank-display[data-rank="Resident"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #f8fafc, #cbd5e1, white) border-box;
  }
  .rank-display[data-rank="Council Member"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #fafaf9, #d6d3d1, white) border-box;
  }
  .rank-display[data-rank="Chief of Police"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #f0f9ff, #93c5fd, white) border-box;
  }
  .rank-display[data-rank="Mayor"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #fff1f2, #fda4af, white) border-box;
  }
  .rank-display[data-rank="Power Broker"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #fefce8, #92400e, white) border-box;
  }
  .rank-display[data-rank="Kingmaker"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #fffbeb, #fcd34d, white) border-box;
  }
  .rank-display[data-rank="Puppet Master"] {
    background:
      linear-gradient(#373737, #373737) padding-box,
      conic-gradient(from var(--angle), white, #faf5ff, #d8b4fe, white) border-box;
  }
  .score-bar {
    background-color: #373737;
    color: white;
  }
  .stat-items {
    background-color: #373737;
    color: white;
  }
  .solved-expressions h3 {
    color: white;
  }
  .message.success {
    color: black;
  }
  .solved-message {
    color: white;
  }
  .score-bar .chevron svg path {
    fill: white;
  }
  .date-picker-container {
    background-color: #373737;
    color: white;
  }
  .date-picker-container .weekdays {
    color: white;
  }
  .date-picker-container .month-nav {
    color: white;
  }
  .date-picker-container .date-cell.no-puzzle {
    background: #414141 !important;
    border-color: #575757 !important;
  }

  /* Dark Mode Custom Keyboard */
  @media (max-width: 640px) {
    .input-container {
      background-color: #2d2d2d;
    }
    .custom-keyboard {
      background-color: #2d2d2d;
    }
    .keyboard-key {
      background-color: #5d5d5d;
      border: none;
      color: white;
    }
    .custom-input {
      background: #2d2d2d;
      color: white;
    }
    .placeholder {
      color: #bbb !important;
    }
  }
  .fan-mail a {
    color: white;
    text-decoration: underline;
  }
  .fan-mail a:hover {
    text-decoration: none;
  }
  .correct {
    color: black;
  }
  .message.success.completion-message {
    color: white;
  }
  .message.success.completion-message a {
    color: #bbb;
  }
  .solved {
    color: black;
  }
  .expression-item .solution {
    color: black;
  }
  .tutorial-completion {
    color: black;
  }
  .tutorial-completion-title {
    color: black;
  }
  .tutorial-completion-text {
    color: black;
  }
  @media (min-width: 641px) {
    .tutorial-close-btn {
      color: white;
    }
    .tutorial-close-btn:hover {
      background: white;
      color: black;
      border-radius: 50%;
    }
  }
  .puzzle-header .exit-button {
    border-color: white;
    color: white;
  }
  .puzzle-header .exit-button:hover {
    background-color: white;
    color: black;
  }
  .tutorial-container {
    background-color: #1e1e1e;
  }
}

/* smaller mobile devices */
/* includes iphone se, iphone 5se, iphone 8 */
/* excludes iphone 13 mini / iphone 13 */
@media (max-width: 375px) and (max-height: 800px) {
  .puzzle-display {
    font-size: 1rem;
  }

  .expression-item {
    font-size: 1rem;
  }
  
  .expression-item .solution {
    font-size: 1rem;
  }

  .keyboard-key {
    height: 2.6rem;
  }

  .custom-input {
    font-size: .9rem;
    height: 35px !important;
    min-height: 0;
    font-size: 18px !important; 
  }

  .mobile-submit-button {
    height: 35px !important;
    font-size: 14px !important;
  }

  .puzzle-header .info-button {
    width: 30px;
    height: 30px;
    font-size: .9rem;
  }

  .puzzle-header .help-button {
    width: 30px;
    height: 30px;
    font-size: .9rem;
  }

  /* Force solid background on mobile for tutorial prompt */
  .help-button.new-player-highlight::after {
    background: rgba(51, 51, 51, 1) !important;
  }

  .help-button.new-player-highlight::before {
    border-bottom-color: rgba(51, 51, 51, 1) !important;
  }

  .puzzle-header h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
  }

  .puzzle-header .puzzle-date {
    font-size: 15px;
    padding: 0 !important;
  }

  .puzzle-header .nav-button {
    padding: 0 12px;
  }

  .puzzle-content {
    top: 65px;
    transition: top 0.3s ease;
  }

  .header-collapsed {
    top: 0;
  }

  .message {
    font-size: .8rem !important;
  }
}

/* Add these styles to your existing bracket.css file */

.puzzle-header .nav-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap; /* Allow wrapping for smaller screens if needed */
}

.puzzle-header .puzzle-date-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.puzzle-header .puzzle-date {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  font-family: var(--main-font);
  font-variant: small-caps;
  color: #1a202c;
  /* cursor, padding, etc. already defined */
}

.puzzle-header .streak-display {
  font-size: 0.8em; /* Smaller than puzzle date */
  color: #555; /* Subdued color */
  margin-top: 0.1rem; /* Small space below the date */
  font-family: var(--main-font);
  text-align: center;
  white-space: nowrap; /* Prevent wrapping if possible */
}

/* Dark mode adjustments for streak display */
html.bracket-city-dark-mode .puzzle-header .puzzle-date {
  color: white;
}
html.bracket-city-dark-mode .puzzle-header .streak-display {
  color: #bbb; /* Lighter gray for dark mode */
}


/* Mobile adjustments for streak display */
@media (max-width: 640px) {
  .puzzle-header .puzzle-date-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Keep this simple for now */
  }

  .puzzle-header .puzzle-date {
    font-size: 18px; /* Slightly smaller on mobile */
    margin: 3px !important; /* Remove extra margin to prevent spacing issues on regular iPhones */
    padding: 3px 4px; /* Slightly reduced vertical padding for the date */
  }

  .puzzle-header .streak-display {
    font-size: 0.75em;
    /* Use a negative margin-top to pull it up */
    margin-top: -10px !important; /* Increased negative margin to avoid touching horizontal line */
    /* line-height: 1.1; /* Can be useful but let's see if negative margin is enough */
  }

  .puzzle-header .nav-container {
    gap: 0.5rem; /* Reduce gap on mobile */
    align-items: center; /* Good for vertical alignment */
  }
}

/* Very small mobile devices */
@media (max-width: 375px) and (max-height: 800px) {
    .puzzle-header .puzzle-date {
        font-size: 15px;
        margin: 5px;
        padding: 2px 4px; /* Even tighter padding for date */
    }
    .puzzle-header .streak-display {
        font-size: 0.7em;
        margin-top: -6px !important; /* Increased negative margin for very small screens */
    }
}

/* Small screen phones - better spacing for streak display (exclude taller iPhones) */
@media screen and (max-width: 375px) and (max-height: 850px) {
    .streak-display {
        margin-top: 10px !important; /* More space between date and streak on small screens */
        padding-top: 5px !important; /* Additional padding for better spacing */
    }
}

/* ===================
   Tutorial Styles
   =================== */
.tutorial-container {
  --tutorial-guidance-bg: #ffe8fa;
  --tutorial-guidance-border: #4a6fa5;
  --tutorial-highlight-border: #f6b73c;
  --tutorial-completion-bg: #e9f7ef;
  --tutorial-completion-border: #27ae60;
  --tutorial-button-bg: #2980b9;
  --tutorial-button-hover: #3498db;
}

/* Tutorial Guidance */
.tutorial-guidance {
  background-color: #fff8e5;
  border-radius: 8px;
  font-family: var(--main-font);
  border: 2px solid #cc9900;
  overflow-y: auto;
  padding: 16px;
  margin: 16px 0;
  display: flex;
  align-items: flex-start;
  position: relative;
}

/* Tutorial close button - hidden by default */
.tutorial-close-btn {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #333;
  align-items: center;
  justify-content: center;
  font-weight: bold;

}

.small-break {
  min-height: 1rem;  /* adjust as needed */
}

@media (max-width: 640px) {
  .small-break {
    min-height: 0.8rem;  /* adjust as needed */
  }
}

.tutorial-guidance.emerge {
  animation: emerge 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes emerge {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.tutorial-guidance.highlight {
  background-color: #fff8e5;
}

@media (max-width: 640px) {
  .tutorial-guidance {
    margin: 0.625rem 0.6rem;
    /*padding: 1rem 0.3125rem !important;  /* 16px 5px */
    font-size: 0.9rem;
  }

  /* Show close button on mobile */
  .tutorial-close-btn {
    display: flex !important;

  }

  /* Keep guidance panel visible just above the input */
  .tutorial-container .tutorial-guidance {
    position: relative !important;
    margin: 0.5rem 0.6rem 0.25rem !important;
    display: flex !important;
    align-items: flex-start !important;
    visibility: visible !important;
    z-index: 10 !important;
    min-height: unset !important;
    max-height: unset !important;
    height: auto !important;
  }

  .tutorial-container .tutorial-puzzle-display {
    margin-bottom: 0.5rem !important;
    flex: none !important;
  }

  .tutorial-container .puzzle-content {
    padding-bottom: 0.75rem;
    min-height: auto !important;
    justify-content: flex-start !important;
  }
}

/* Tutorial Message */
.tutorial-message {
  font-size: 18px;
  line-height: 1.5;
  padding-right: 15px; /* Ensure space away from close button */
  white-space: pre-wrap;
}


.tutorial-message-body {
  min-width: 220px;
  white-space: pre-wrap;
}

.tutorial-message-body-text {
  display: inline;
}


.tutorial-message strong {
  font-weight: 600;
}

.tutorial-message a {
  text-decoration: none;
  border-bottom: 1px solid;
  padding-bottom: 1px;
  transition: color 0.2s;
}

.tutorial-message a:hover {
  opacity: 0.8;
}

.tutorial-message .emoji {
  font-size: 1.2em;
}

/* Tutorial Continue Button */
.input-container.continue-mode {
  padding: 0.75rem 0;
}

/* Remove any bottom spacing in continue mode */
.tutorial-container .input-container.continue-mode {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

/* Force guidance panel to be close to continue button */
.tutorial-container .tutorial-guidance + .input-container.continue-mode {
  margin-top: 0.25rem !important;
}

.input-container.continue-mode .input-submit-wrapper.continue-mode {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 0.75rem;
}

.tutorial-container .submit-answer {
  padding: 0 1.5rem;
  height: 60px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--mono-font);
  white-space: nowrap;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.tutorial-container .submit-answer:hover {
  background-color: #1d4ed8;
}

.tutorial-container .submit-answer:active {
  background-color: #1e40af;
  transform: scale(0.98);
}

.tutorial-container .tutorial-continue-button {
  padding: 0 1.5rem;
  height: 44px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--mono-font);
  white-space: nowrap;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background-color 0.2s ease, transform 0.15s ease;
  min-width: 180px;
}

.tutorial-container .tutorial-continue-button:hover {
  background-color: #1d4ed8;
}

.tutorial-container .tutorial-continue-button:active {
  background-color: #1e40af;
  transform: scale(0.98);
}

.tutorial-container .tutorial-continue-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.4);
  outline-offset: 3px;
}

/* Play for Real button green states */
.tutorial-container .play-for-real-button {
  background-color: #28a745 !important;
}

.tutorial-container .play-for-real-button:hover {
  background-color: #218838 !important;
}

.tutorial-container .play-for-real-button:active {
  background-color: #1e7e34 !important;
}

/* Hide keyboard completely when continue button is shown */
.tutorial-container .custom-keyboard.continue-mode {
  display: none !important;
}

/* Also hide keyboard when input container is in continue mode */
.tutorial-container .input-container.continue-mode .custom-keyboard {
  display: none !important;
}

/* Hide keyboard when it's disabled (steps 4 & 5) */
.tutorial-container .input-container[style*="opacity: 0.5"] .custom-keyboard,
.tutorial-container .input-container.disabled .custom-keyboard {
  display: none !important;
}

.tutorial-text-accent {
  color: #0056cc;
  font-weight: 600;
}

.tutorial-exit-link {
  text-decoration: underline;
  cursor: pointer !important;
}

.tutorial-exit-link:hover {
  opacity: 0.7;
}

.tutorial-text-highlight {
  background-color: #D6E0FF;
    border-radius: 3px;
    padding: 2px 4px;
    margin: -2px 0;
    transition: background-color 0.3s ease;
    color: black;
    font-weight: 500;
    font-family: CustomMono, var(--mono-font);
}

.tutorial-text-solved {
  background-color: #99EBDD;
    border-radius: 3px;
    padding: 2px 4px;
    margin: -2px 0;
    transition: background-color 0.3s ease;
    cursor: pointer;
    color: black;
    font-weight: 500;
    font-family: CustomMono, var(--mono-font);
}

.tutorial-text-muted {
  color: #64748b;
}

.tutorial-text-success {
  color: #1f7a4d;
  font-weight: 600;
}

/* Tutorial Blur Effect */
.tutorial-blur {
  filter: blur(2px);
  opacity: 0.4;
  transition: all 0.3s ease;
}

@media (max-width: 640px) {
  .tutorial-message {
    font-size: 16px;
    line-height: 1.5;
    padding-right: 20px; /* More space on mobile */
  }

  /* Ensure continue button doesn't overlap on very small screens */
  .tutorial-message-body {
    min-width: 180px;
  }

  .input-container.continue-mode {
    padding: 0.5rem 0;
  }

  .input-container.continue-mode .input-submit-wrapper.continue-mode {
    margin-bottom: 0.5rem;
  }

  .tutorial-container .tutorial-continue-button {
    width: 100%;
  }
}

/* Tutorial Puzzle Display */
.tutorial-puzzle-display {
  height: 220px !important;
  min-height: 260px !important;
  max-height: 220px !important;
  min-width: 620px;
  overflow-y: auto;
  background: white;
  border-radius: 0.5rem;
  padding: 1rem;
  font-family: CustomMono, var(--mono-font);
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: break-word;
  transition: none;
  cursor: default;
  user-select: none;
}

/* Active clues default to non-clickable cursor (steps 4 & 5 will override with inline style) */
.tutorial-puzzle-display .active-clue {
  cursor: default;
}

.tutorial-puzzle-display.completed {
  height: auto !important;
  min-height: 260px !important;
  max-height: 260px !important;
  min-width: 620px;
}

@media (max-width: 640px) {
  .tutorial-overlay {
    align-items: stretch;
  }

  .tutorial-container {
    width: 100% !important;
  }

  .tutorial-overlay .tutorial-container {
    max-width: 100% !important;
    align-self: stretch;
    flex: 1 1 auto;
  }


  .tutorial-puzzle-display {
    height: 160px !important;
    min-height: 160px !important;
    max-height: 160px !important;
    padding: 0.8rem;
    font-size: 1.1rem;
    min-width: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Larger puzzle display only for steps 0 & 1 (continue mode) */
  .tutorial-container[data-step="0"] .tutorial-puzzle-display,
  .tutorial-container[data-step="1"] .tutorial-puzzle-display {
    height: 220px !important;
    min-height: 220px !important;
    max-height: 220px !important;
    min-width: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .tutorial-container[data-step="4"] .input-container,
  .tutorial-container[data-step="4"] .custom-keyboard,
  .tutorial-container[data-step="5"] .input-container,
  .tutorial-container[data-step="5"] .custom-keyboard {
    display: none !important;
  }

  .tutorial-puzzle-display.completed {
    height: 160px !important;
    min-height: 160px !important;
    max-height: 160px !important;
    min-width: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Tutorial Highlights and Animations */
.spotlight {
  background-color: #D6E0FF;
  box-shadow: 0 0 0 2px #D6E0FF;
  border-radius: 4px;
}

.correct {
  background-color: #99EBDD;
  box-shadow: 0 0 0 2px #99EBDD;
  border-radius: 4px;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 #B8C8FF;
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 193, 7, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    transform: scale(1);
  }
}

@keyframes tap-hint {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.active-clue.tutorial-highlight {
  box-shadow: 0 0 0 2px #B8C8FF;
  animation: pulse 2.5s infinite;
  background-color: #D6E0FF;
  font-weight: 500;
}

.active-clue.tap-hint {
  animation: tap-hint 2s infinite;
}

/* Tutorial Completion */
.tutorial-completion {
  background-color: #e9f7ef;
  padding: 20px;
  border-radius: 8px;
  margin: 10px 10px 0px 10px;
  text-align: center;
  border: 2px solid #27ae60;
  font-family: var(--mono-font);
  animation: fade-in 0.5s ease-in-out;
}

.tutorial-completion-title {
  font-size: 20px;
  margin-bottom: 10px;
}

.tutorial-completion-text {
  font-size: 16px;
}

.tutorial-completion-wrapper {
  margin: 0px;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(-10px); 
  }
  to {
    opacity: 1;
    transform: translateY(0); 
  }
}

/* Play Game Button */
#playGameButton {
  margin-top: 15px;
  padding: 10px 20px;
  background-color: #2980b9;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.2s, transform 0.1s;
}

#playGameButton:hover {
  background-color: #3498db;
}

#playGameButton:active {
  transform: scale(0.98);
}

/* First Letter Hint */
.first-letter-hint {
  font-weight: bold;
  color: #0c63e4;
}

/* Submit button and input wrapper */
.tutorial-container .input-submit-wrapper {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.tutorial-container .submit-answer {
  padding: 0 1.5rem;
  height: 60px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--mono-font);
  white-space: nowrap;
  font-size: 1rem;
}

.tutorial-container .submit-answer:hover {
  background-color: #1d4ed8;
}

.tutorial-container .submit-answer:active {
  background-color: #1e40af;
  transform: scale(0.98);
}

.tutorial-container .puzzle-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  width: 100%;
  max-width: 100%;
}

.tutorial-container .tutorial-puzzle-display {
  flex: 1;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}


.tutorial-container .tutorial-guidance {
  margin: 0 0 0.5rem 0;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  display: block !important;
  visibility: visible !important;
}

.tutorial-container .input-container {
  margin-top: 0;
  flex-shrink: 0;
}

.tutorial-container .tutorial-guidance + .input-container {
  margin-top: 0;
}

/* Desktop only: Add more space between guidance and input (but not continue button) */
@media (min-width: 641px) {
  .tutorial-container .tutorial-guidance + .input-container:not(.continue-mode) {
    margin-top: 1.5rem;
  }
}

.tutorial-container .tutorial-guidance + .input-container.continue-mode {
  margin-top: 0;
}

.tutorial-container .mobile-submit-button {
  background-color: #2563eb !important;
  color: white !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
}

/* Tutorial header mobile optimizations - hide header on all mobile devices */
@media (max-width: 640px) {
  .tutorial-header {
    display: none !important;
  }
  
  .tutorial-container .puzzle-content {
    top: 0 !important;
    padding-top: 0.5rem !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Override all desktop min-width rules on mobile */
  .tutorial-puzzle-display,
  .tutorial-puzzle-display.completed {
    min-width: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Ultra-aggressive fix for completed tutorial step */
  .tutorial-container .tutorial-puzzle-display.completed,
  .tutorial-container.completed .tutorial-puzzle-display,
  .tutorial-puzzle-display.completed {
    min-width: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* FORCE tutorial to ignore ALL completion styles and use normal layout */
  .tutorial-container.completed,
  .puzzle-container.tutorial-container.completed {
    position: static !important;
    height: auto !important;
    min-height: auto !important;
    overflow-y: visible !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .tutorial-container.completed .puzzle-content,
  .puzzle-container.tutorial-container.completed .puzzle-content {
    position: static !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0.5rem !important;
    width: 100% !important;
    max-width: 100% !important;
    top: 0 !important;
    padding-top: 0.5rem !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 100% !important;
  }
}
