    :root {
      --bg: #ffffff;
      --bg-alt: #f5f5f5;
      --border: #d3d3d3;
      --border-dark: #999999;
      --text: #111111;
      --muted: #6f6f6f;
      --accent: #ffcf33;
      --danger: #c53030;
      --selected-bg: #fa6eff;   /* light purple */
      --selected-text: #4a74ff; /* blue */
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
      background: var(--bg);
      color: var(--text);
      display: flex;
      justify-content: center;
      align-items: flex-start;
      min-height: 100vh;
      touch-action: manipulation;
    }

    .app { width: 100%; max-width: 520px; padding: 16px; }

    header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      border-bottom: 1px solid var(--border);
      padding-bottom: 8px;
    }

    .title {
      font-family: "Georgia", "Times New Roman", serif;
      font-size: 26px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .controls {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 2px;
      font-size: 11px;
      color: var(--muted);
      text-align: right;
    }

    .mode-label {
      text-transform: uppercase;
      letter-spacing: 0.12em;
      font-size: 10px;
    }

    /* Hide the numBig select while keeping it for internal use */
    .hidden-config { display: none; }

    /* X link (icon) */
    .x-link {
      margin-top: 6px;
      width: 30px;
      height: 30px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: #ffffff;
      text-decoration: none;
    }

    .x-link:hover {
      border-color: var(--border-dark);
    }

    .x-icon {
      width: 14px;
      height: 14px;
      fill: var(--text);
      opacity: 0.8;
    }

    .x-link:hover .x-icon {
      opacity: 1;
    }

    main {
      display: flex;
      flex-direction: column;
      gap: 16px;
      margin-top: 8px;
    }

    .section { background: transparent; }

    .section-label {
      text-transform: uppercase;
      letter-spacing: 0.16em;
      font-size: 10px;
      color: var(--muted);
      text-align: center;
      margin-bottom: 4px;
    }

    .target-value {
      font-size: 40px;
      font-weight: 600;
      text-align: center;
    }

    .tiles {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 8px;
    }

    .tile {
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.tile:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.tile:active {
  transform: translateY(0);
}





    .tile {
      width: 52px;
      height: 52px;
      border-radius: 6px;
      border: 1px solid var(--border-dark);
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
      font-weight: 600;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
      transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }

    .tile {
  color: #111111 !important;
  -webkit-text-fill-color: #111111;
}





.tile.used {
 background: var(--selected-bg);
  color: var(--selected-text);
  border-color: var(--selected-text);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2);
  -webkit-text-fill-color: var(--selected-text);
}


    .attempt-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.16em;
      color: var(--muted);
      margin-bottom: 4px;
    }

    .expression-display {
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--bg-alt);
      padding: 8px 10px;
      font-family: "Menlo", "Consolas", monospace;
      font-size: 14px;
      min-height: 36px;
      display: flex;
      align-items: center;
    }

    #expressionInput {
      width: 100%;
      border: none;
      background: transparent;
      color: var(--text);
      font-family: inherit;
      font-size: inherit;
    }

    #expressionInput:focus { outline: none; }

    #expressionInput::placeholder { color: var(--muted); }

    button {
      border: none;
      border-radius: 4px;
      padding: 8px 12px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }

    button {
  -webkit-tap-highlight-color: transparent;
}

    button.primary {
      background: var(--accent);
      color: #111111;
      border: 1px solid #e0b72b;
    }

    button.primary:disabled {
      opacity: 0.5;
      cursor: default;
    }

    button.secondary {
      background: #ffffff;
      color: var(--text);
      border: 1px solid var(--border);
      font-size: 11px;
    }

    button.secondary.small {
      padding: 6px 8px;
      font-size: 11px;
    }

    .message {
      margin-top: 6px;
      font-size: 13px;
      color: var(--text);
    }

    .message.error { color: var(--danger); }

    .footer-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 16px;
      font-size: 13px;
    }

    .footer-row code {
      font-size: 11px;
      background: var(--bg-alt);
      padding: 2px 4px;
      border-radius: 3px;
    }

    .hint {
      font-size: 11px;
      color: var(--muted);
    }

    #authPanel {
      margin: 8px 0 4px 0;
      border-bottom: 1px solid var(--border);
      padding-bottom: 8px;
    }

    #authForms {
      margin-top: 6px;
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }

    #authForms input {
      flex: 1;
      min-width: 140px;
      padding: 6px 8px;
      border-radius: 4px;
      border: 1px solid var(--border);
      background: #ffffff;
      font-size: 12px;
    }

    #authForms input:focus {
      outline: none;
      border-color: var(--border-dark);
    }

    #authForms input::placeholder { color: var(--muted); }

    /* Keypad styling */
    .keypad {
      margin-top: 8px;
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 6px;
    }

    /* Visually group operators */
.keypad button.operator {
  background: #fafafa;
  border-color: var(--border-dark);
}

/* Brackets feel like a pair */
.keypad button[data-char="("],
.keypad button[data-char=")"] {
  background: #f0f0f0;
}

/* Cursor controls feel separate */
.keypad button.control {
  background: #ffffff;
  border-style: dashed;
}

/* Clear + Confirm feel like actions */
.keypad #clearBtn {
  background: #f8f8f8;
}

.keypad #submitBtn {
  font-size: 14px;
}




    .keypad button {
      width: 100%;
      padding: 8px 0;
      font-size: 14px;
      text-transform: none;
      letter-spacing: 0;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: #ffffff;
      color: #111111;
    }

    .keypad button.operator { font-weight: 700; }
    .keypad button.control { font-size: 11px; }
    .keypad button.primary { border-width: 1px; }

    /* Modal base */
    .modal {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.55);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 50;
    }

    .modal-inner {
      background: #ffffff;
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 16px 20px;
      width: 92%;
      max-width: 380px;
      color: var(--text);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    }

    .modal-title {
      font-weight: 700;
      font-size: 16px;
      margin: 0;
    }

    .modal-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
      gap: 10px;
    }

    .modal-body { font-size: 13px; line-height: 1.45; color: var(--text); }
    .modal-body .muted { color: var(--muted); }

    /* Seasonal snow (subtle) */
    #snowCanvas {
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100vh;
      pointer-events: none;
      z-index: 5; /* above background, below modals */
      opacity: 0.35;
    }

    @media (max-width: 480px) {
      .app { padding: 10px; }
      .keypad button { padding: 10px 0; font-size: 16px; }
      .tile { width: 56px; height: 56px; font-size: 22px; }
    }

    @media (max-width: 360px) {
      .title { font-size: 22px; }
    }

    @media (max-width: 400px) {
      .footer-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
      }

      .footer-row > div:last-child {
        align-self: flex-end;
      }
    }
   #expressionInput {
  caret-color: #111111;
  background-color: var(--bg-alt);
}


