/* Cabbagehead — softer blue/amber palette */

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

:root {
  --blue: #3a6fa8;
  --blue-dark: #1e3f6b;
  --blue-light: #5588c4;
  --blue-bg: #eef3fb;
  --amber: #c8920e;
  --amber-light: #e8b030;
  --gray-dark: #3a3a3a;
  --gray-mid: #787c7e;
  --gray-light: #d3d6da;
  --tile-size: clamp(44px, 11vw, 62px);
  --key-height: clamp(48px, 12vw, 58px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: #f4f6f9;
  font-family: var(--font);
  color: var(--gray-dark);
}

/* Header */
header {
  background: var(--blue-dark);
  color: white;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.header-inner {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: white;
  text-transform: uppercase;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.username {
  font-size: 0.85rem;
  opacity: 0.75;
}
.btn-about {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 3px 8px;
}
.btn-about:hover { color: var(--amber-light); }
.btn-signup {
  color: white;
  text-decoration: none;
  font-size: 0.8rem;
  border: 1px solid rgba(255,255,255,0.5);
  padding: 3px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  transition: background 0.15s;
}
.btn-signup:hover { background: rgba(255,255,255,0.2); }
.btn-logout {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.8rem;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 3px 8px;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.btn-logout:hover { border-color: rgba(255,255,255,0.7); }

main {
  max-width: 500px;
  margin: 0 auto;
  padding: 16px;
}

/* Messages */
.messages { margin-bottom: 12px; }
.message {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.message-error   { background: #fde8e8; color: #c00; border: 1px solid #f9b0b0; }
.message-success { background: #e8f5e8; color: #1a6e1a; border: 1px solid #9fd49f; }
.message-info    { background: var(--blue-bg); color: var(--blue-dark); border: 1px solid #b0c8e8; }

/* Login / Signup */
.login-wrap {
  max-width: 340px;
  margin: 40px auto 0;
  background: white;
  padding: 32px 28px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.login-wrap h2 {
  text-align: center;
  color: var(--blue-dark);
  margin-bottom: 24px;
  font-size: 1.4rem;
}
.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-mid);
  margin-bottom: 4px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.login-form input[type=text],
.login-form input[type=password] {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--gray-light);
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.login-form input:focus { border-color: var(--blue); }
.login-form input[type=text],
.login-form input[type=password],
.login-form input[type=email] { display: block; width: 100%; }
.login-form ul { list-style: none; padding: 0; }
.field-error { color: #c00; font-size: 0.82rem; margin-top: 3px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 0.88rem; color: var(--gray-mid); }
.auth-switch a { color: var(--blue); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.error-msg {
  background: #fde8e8;
  color: #c00;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.error-msg.hidden { display: none; }

/* Buttons */
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  background: var(--blue);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--blue-light); }

/* Option select */
.select-wrap h2 {
  text-align: center;
  color: var(--blue-dark);
  margin-bottom: 16px;
  font-size: 1.3rem;
}
.direction-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 10px;
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--gray-dark);
}
.tab-btn.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.opts-group {
  margin-bottom: 20px;
}

.opts-group-label {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gray-light);
}

.opts-sub-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-mid);
  margin: 14px 0 6px;
}
.hidden { display: none !important; }

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  padding-bottom: 4px;
}
.option-card {
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.option-card:hover {
  border-color: var(--blue-light);
  background: var(--blue-bg);
}
.option-card.selected {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}
.opt-range {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
  margin-bottom: 5px;
}
.opt-range-letter {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--blue-dark);
  line-height: 1;
  min-width: 14px;
}
.option-card.selected .opt-range-letter { color: white; }
.opt-range-line {
  flex: 1;
  height: 2px;
  background: var(--gray-light);
  border-radius: 1px;
  min-width: 6px;
  max-width: 28px;
}
.option-card.selected .opt-range-line { background: rgba(255,255,255,0.35); }
.opt-detail {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--gray-mid);
  margin-bottom: 6px;
}
.option-card.selected .opt-detail { color: rgba(255,255,255,0.85); }
.opt-tile-row {
  display: flex;
  gap: 2px;
  justify-content: center;
  flex-wrap: wrap;
}
.opt-tile-sq {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--blue);
  flex-shrink: 0;
}
.option-card.selected .opt-tile-sq { background: rgba(255,255,255,0.75); }

.selection-preview {
  margin-top: 16px;
  background: var(--blue-bg);
  border: 2px solid var(--blue);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}
.selection-preview p {
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 0;
}
.selection-preview .btn-primary {
  margin-top: 12px;
}

/* Anonymous hint banner */
.anon-hint {
  width: 100%;
  background: #fffbea;
  border: 1px solid #f0d060;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #7a6000;
  text-align: center;
}
.anon-hint a { color: var(--blue); font-weight: 600; text-decoration: none; }
.anon-hint a:hover { text-decoration: underline; }

/* Play screen */
.play-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.game-info {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.game-badge {
  font-size: 0.75rem;
  background: var(--blue);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.btn-new {
  font-size: 0.8rem;
  color: var(--blue);
  text-decoration: none;
  border: 1.5px solid var(--blue);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-new:hover { background: var(--blue-bg); }

/* Guess grid */
.grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  max-width: min(360px, 95vw);
}
.guess-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 800;
  border-radius: 4px;
  text-transform: uppercase;
  user-select: none;
  flex-shrink: 0;
}
.tile-empty {
  border: 2px solid var(--gray-light);
  background: white;
}
.tile-input {
  border: 2px solid var(--gray-mid);
  background: white;
  transition: border-color 0.1s;
}
.tile-correct {
  background: var(--blue);
  color: white;
  border: 2px solid var(--blue);
}
.tile-present {
  background: var(--amber);
  color: white;
  border: 2px solid var(--amber);
}
.tile-absent {
  background: var(--gray-mid);
  color: white;
  border: 2px solid var(--gray-mid);
}

/* Status messages */
.status-msg {
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 8px;
  text-align: center;
  min-height: 0;
}
.status-won {
  background: var(--blue);
  color: white;
}
.status-lost {
  background: var(--gray-dark);
  color: white;
}

.btn-results {
  display: inline-block;
  margin-top: 4px;
  padding: 10px 20px;
  background: var(--blue);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.btn-results:hover { background: var(--blue-light); }

/* Keyboard toggle */
.kb-toggle-wrap {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: 480px;
}
.kb-toggle-btn {
  font-size: 0.72rem;
  padding: 3px 10px;
  background: white;
  border: 1px solid var(--gray-light);
  border-radius: 12px;
  cursor: pointer;
  color: var(--gray-mid);
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
}
.kb-toggle-btn:hover { border-color: var(--blue); color: var(--blue); }

/* Keyboard */
.keyboard {
  width: 100%;
  max-width: 480px;
  padding: 4px 0;
}
.kb-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 5px;
}
.kb-alpha .kb-row {
  flex-wrap: wrap;
}
.key-gap {
  width: clamp(28px, 7vw, 42px);
  height: var(--key-height);
  flex-shrink: 0;
  /* invisible spacer preserving QWERTY column alignment */
}
.key {
  height: var(--key-height);
  min-width: clamp(28px, 7vw, 42px);
  padding: 0 4px;
  border: none;
  border-radius: 6px;
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.05s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.key:active { transform: scale(0.93); }

.key-unused   { background: var(--gray-light); color: var(--gray-dark); }
.key-absent   { background: var(--gray-mid);   color: white; }
.key-present  { background: var(--amber);      color: white; }
.key-correct  { background: var(--blue);       color: white; }
.key-action   { background: var(--gray-light); color: var(--gray-dark); min-width: clamp(40px, 9vw, 54px); }
.key-enter    { background: var(--blue-dark);  color: white; min-width: clamp(52px, 11vw, 70px); font-size: 0.7rem; letter-spacing: 0.05em; }

/* About page */
.about-wrap { max-width: 560px; margin: 0 auto; }
.about-wrap h2 { color: var(--blue-dark); margin-bottom: 16px; font-size: 1.4rem; }
.about-wrap h3 { color: var(--blue-dark); margin: 24px 0 8px; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }
.about-wrap p, .about-wrap li { font-size: 0.95rem; line-height: 1.6; color: var(--gray-dark); }
.about-wrap ul { padding-left: 20px; margin-bottom: 8px; }
.about-wrap a { color: var(--blue); }
.tile-legend { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.legend-row { display: flex; align-items: center; gap: 12px; }
.legend-row .tile { width: 40px; height: 40px; font-size: 1rem; flex-shrink: 0; }
.legend-row span { font-size: 0.9rem; }
.credit-block { background: #f5f8ff; border-left: 3px solid var(--blue); padding: 12px 16px; border-radius: 0 6px 6px 0; margin: 10px 0; }
.credit-block p { margin: 0; font-size: 0.88rem; line-height: 1.7; }
.btn-back { display: inline-block; margin-top: 24px; color: var(--blue); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.btn-back:hover { text-decoration: underline; }

/* Results page */
.results-wrap { max-width: 560px; margin: 0 auto; }
.results-wrap h2 { color: var(--blue-dark); margin-bottom: 20px; font-size: 1.4rem; }
.no-results { color: var(--gray-mid); font-size: 0.95rem; }
.no-results a { color: var(--blue); font-weight: 600; text-decoration: none; }
.results-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.result-card {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border-left: 4px solid var(--gray-light);
}
.result-card.result-won  { border-left-color: var(--blue); }
.result-card.result-lost { border-left-color: var(--gray-mid); }
.result-card.result-abandoned { border-left-color: var(--gray-light); }

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.result-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.result-badge-won       { background: var(--blue);      color: white; }
.result-badge-lost      { background: var(--gray-mid);  color: white; }
.result-badge-abandoned { background: var(--gray-light); color: var(--gray-mid); }

.result-config { font-size: 0.82rem; color: var(--gray-mid); }
.result-date   { font-size: 0.78rem; color: var(--gray-light); margin-left: auto; }
.result-word   { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.1em; color: var(--blue-dark); margin-bottom: 2px; }
.result-guesses { font-size: 0.8rem; color: var(--gray-mid); margin-bottom: 8px; }

.result-grid { display: flex; flex-direction: column; gap: 3px; }
.result-row  { display: flex; gap: 3px; }
.result-tile {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}
/* tile-correct/present/absent already defined above — reused here */

.result-grid-toggle {
  cursor: pointer;
  position: relative;
}

.expand-hint {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--blue);
  font-weight: 600;
  user-select: none;
  letter-spacing: 0.01em;
}
.result-full-grid {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.result-full-grid .expand-hint {
  margin-top: 10px;
}

.result-full-row {
  justify-content: flex-start;
}
.result-full-tile {
  --tile-size: clamp(32px, 8vw, 44px);
  font-size: clamp(0.8rem, 2.5vw, 1.1rem);
}

/* Hamburger nav */
.hamburger {
  display: none;
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
@media (max-width: 480px) {
  header { position: relative; }
  .hamburger { display: block; }
  .header-right {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--blue-dark);
    padding: 4px 0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    z-index: 100;
  }
  .header-right.open { display: flex; }
  .header-right .btn-about,
  .header-right .btn-signup,
  .header-right .username {
    display: block;
    font-size: 0.95rem;
    padding: 13px 20px;
    border-radius: 0;
    background: none;
    border: none;
    text-align: left;
  }
  .header-right .btn-about:hover { background: rgba(255,255,255,0.07); }
  .header-right .btn-signup { border: none; color: white; }
  .header-right form { display: block !important; }
  .header-right .btn-logout {
    display: block;
    width: 100%;
    font-size: 0.95rem;
    padding: 13px 20px;
    text-align: left;
    border: none;
    border-radius: 0;
    color: rgba(255,255,255,0.85);
  }
  .header-right .username {
    opacity: 0.55;
    font-size: 0.82rem;
    padding: 8px 20px 2px;
  }
}

/* Selection modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.selection-modal {
  background: white;
  border-radius: 16px;
  padding: 26px 28px 20px;
  max-width: 280px;
  width: 88%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.modal-direction {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-mid);
  margin-bottom: 2px;
}
.modal-range {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 12px 6px;
}
.modal-range-letter {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--blue-dark);
  line-height: 1;
  min-width: 36px;
}
.modal-range-line {
  flex: 1;
  height: 3px;
  background: var(--gray-light);
  border-radius: 2px;
}
.modal-detail {
  font-size: 0.9rem;
  color: var(--gray-mid);
  margin: 8px 0 14px;
}
.modal-tiles {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.modal-tile-sq {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--blue);
  flex-shrink: 0;
}
.btn-select-other {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: none;
  color: var(--gray-mid);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1.5px solid var(--gray-light);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
}
.btn-select-other:hover { border-color: var(--blue); color: var(--blue); }

/* ── Header avatar & friend-request badge ── */
.header-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.4);
  text-decoration: none;
  flex-shrink: 0;
  background: var(--blue);
}
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-avatar .avatar-initials { font-size: 0.8rem; font-weight: 700; color: white; }

.btn-requests { position: relative; }
.req-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e03b3b;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
  line-height: 1;
  vertical-align: middle;
}

/* ── Avatar component (reused across pages) ── */
.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: white;
  font-weight: 800;
  border-radius: 50%;
  width: 100%;
  height: 100%;
  font-size: 0.9rem;
}
.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.6rem;
  border-radius: 50%;
}
.result-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--gray-light);
}
.result-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Profile page ── */
.profile-wrap { max-width: 480px; margin: 0 auto; }
.profile-wrap h2 { color: var(--blue-dark); margin-bottom: 10px; font-size: 1.4rem; }
.profile-note {
  font-size: 0.82rem;
  color: var(--gray-mid);
  background: var(--blue-bg);
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 20px;
  line-height: 1.5;
}
.profile-note strong { color: var(--blue-dark); }

.profile-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gray-mid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 14px 0 4px;
}
.profile-form input[type=text],
.profile-form input[type=email],
.profile-form input[type=tel],
.profile-form select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--gray-light);
  border-radius: 6px;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
  background: white;
  color: var(--gray-dark);
}
.profile-form input:focus,
.profile-form select:focus { border-color: var(--blue); }
.field-hint { font-size: 0.75rem; color: var(--gray-mid); margin-top: 3px; }

.form-row { display: flex; gap: 12px; }
.form-col { flex: 1; }

.phone-row { display: flex; gap: 8px; }
.phone-cc { flex: 0 0 auto; width: 185px; }
.phone-num { flex: 1; }

/* Avatar upload */
.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.btn-upload {
  font-size: 0.82rem;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--blue);
  padding: 5px 14px;
  border-radius: 6px;
  background: none;
  transition: background 0.15s;
}
.btn-upload:hover { background: var(--blue-bg); }

.profile-links { margin-top: 20px; }

/* ── Find friends page ── */
.find-form { margin-bottom: 4px; }
.find-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.find-tab {
  flex: 1;
  padding: 9px;
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  color: var(--gray-dark);
  transition: all 0.15s;
}
.find-tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.find-panel { margin-bottom: 4px; }

.search-form { margin-bottom: 20px; }
.search-row { display: flex; gap: 8px; }
.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--gray-light);
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--blue); }
.btn-search {
  padding: 10px 18px;
  background: var(--blue);
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-search:hover { background: var(--blue-light); }

.search-results { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.search-result-card, .request-card {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.result-user-info { display: flex; align-items: center; gap: 12px; }
.result-username { font-size: 1rem; font-weight: 700; color: var(--blue-dark); }

.friend-status-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  text-decoration: none;
}
.friend-accepted { background: var(--blue-bg); color: var(--blue-dark); }
.friend-pending  { background: #fff8e1; color: #8a6000; }
.friend-declined { background: #fde8e8; color: #a00; }

.btn-invite {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 14px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-invite:hover { background: var(--blue-light); }

/* ── Friend requests page ── */
.requests-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.request-date { font-size: 0.75rem; color: var(--gray-mid); display: block; margin-top: 2px; }
.request-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-accept {
  padding: 7px 14px;
  background: var(--blue);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-accept:hover { background: var(--blue-light); }
.btn-decline {
  padding: 7px 14px;
  background: none;
  color: var(--gray-mid);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1.5px solid var(--gray-light);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
}
.btn-decline:hover { border-color: var(--gray-mid); color: var(--gray-dark); }

/* ── Friends page ── */
.friends-wrap { max-width: 560px; margin: 0 auto; }
.friends-wrap h2 { color: var(--blue-dark); margin-bottom: 16px; font-size: 1.4rem; }

.friend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.friend-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 8px;
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: 24px;
  text-decoration: none;
  color: var(--gray-dark);
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.friend-chip:hover { border-color: var(--blue-light); background: var(--blue-bg); }
.friend-chip.active { border-color: var(--blue); background: var(--blue); color: white; }
.friend-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.friend-chip-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friend-chip-avatar .avatar-initials { font-size: 0.75rem; }
.friend-chip.active .friend-chip-avatar { border: 1.5px solid rgba(255,255,255,0.5); }

.friend-games-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.friend-games-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--blue);
}
.friend-games-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friend-games-header h3 { font-size: 1.1rem; color: var(--blue-dark); margin: 0; }

.friend-games-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.friend-game-card {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border-left: 4px solid var(--gray-light);
}
.friend-game-card.friend-shared { border-left-color: var(--blue); }

.friend-game-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.shared-word {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--blue-dark);
  margin-bottom: 12px;
}

/* Side-by-side comparison */
.comparison-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.comparison-col { flex: 1; min-width: 120px; }
.comparison-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-mid);
  margin-bottom: 6px;
}
.comp-tile-grid { display: flex; flex-direction: column; gap: 3px; }
.comp-row { display: flex; gap: 3px; }
.comp-tile {
  width: clamp(24px, 6vw, 36px);
  height: clamp(24px, 6vw, 36px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.6rem, 2vw, 0.85rem);
  font-weight: 800;
  border-radius: 3px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* Friend summary (unplayed) */
.friend-summary-tiles {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
}
.play-this-wrap { margin-top: 4px; }
.btn-play-this {
  padding: 8px 18px;
  background: var(--blue);
  color: white;
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
  letter-spacing: 0.03em;
}
.btn-play-this:hover { background: var(--blue-light); }

/* ── Staff codes page ── */
.staff-code-form {
  background: white;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 8px;
}
.staff-code-form h3 {
  font-size: 1rem;
  color: var(--blue-dark);
  margin-bottom: 14px;
}
.code-gen-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.code-gen-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-mid);
  white-space: nowrap;
}
.code-len-input {
  width: 72px;
  padding: 8px 10px;
  border: 2px solid var(--gray-light);
  border-radius: 6px;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
}
.code-len-input:focus { border-color: var(--blue); }

.codes-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.code-card {
  background: white;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border-left: 4px solid var(--blue);
}
.code-card.code-expired { border-left-color: var(--gray-light); opacity: 0.65; }

.code-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.code-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.04em;
}
.badge-active  { background: var(--blue-bg); color: var(--blue-dark); }
.badge-expired { background: var(--gray-light); color: var(--gray-mid); }
.code-min-len { font-weight: 700; color: var(--blue-dark); }
.code-by { color: var(--gray-mid); }

.code-url-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blue-bg);
  border: 1px solid #c4d8f0;
  border-radius: 6px;
  padding: 8px 12px;
}
.code-url {
  flex: 1;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--blue-dark);
  word-break: break-all;
  user-select: all;
}
.btn-copy {
  padding: 5px 12px;
  background: var(--blue);
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-copy:hover { background: var(--blue-light); }
.code-url-expired { font-size: 0.8rem; color: var(--gray-mid); margin: 0; }

/* ── Signup: invite note & error ── */
.signup-code-note {
  background: var(--blue-bg);
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: var(--blue-dark);
  margin-bottom: 16px;
  line-height: 1.5;
}

.mobile-only-link { display: none; }

/* Mobile tweaks for new pages */
@media (max-width: 480px) {
  .header-avatar { display: none; }
  .mobile-only-link { display: block; }
  .phone-row { flex-direction: column; }
  .phone-cc { width: 100%; }
  .comparison-grid { gap: 8px; }
  .search-result-card, .request-card { flex-direction: column; align-items: flex-start; }
  .result-action, .request-actions { width: 100%; justify-content: flex-start; margin-top: 4px; }
}

/* ─── Challenges ─────────────────────────────────────────────────────────── */

.challenge-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 3px;
  background: #6a3faa;
  color: #fff;
  vertical-align: middle;
}

.challenge-blocked {
  background: var(--blue-bg);
  border-left: 3px solid var(--blue);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
  color: var(--gray-dark);
  margin-bottom: 20px;
}

.challenge-blocked-inline {
  font-size: 0.8rem;
  color: var(--gray-mid);
  margin: 4px 0 0;
}

.challenge-intro {
  font-size: 0.95rem;
  color: var(--gray-mid);
  margin-bottom: 14px;
}

.challenge-pending-card {
  border-left-color: #6a3faa;
}

.challenge-pick-list {
  cursor: pointer;
}

.challenge-pick-card {
  display: block;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.challenge-pick-card input[type="radio"] {
  display: none;
}

.challenge-pick-card:has(input:checked) {
  border-left-color: #6a3faa;
  background: #f6f0ff;
}

.challenge-submit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

.btn-back-inline {
  font-size: 0.9rem;
  color: var(--gray-mid);
  text-decoration: none;
}

.btn-back-inline:hover { color: var(--blue); }

/* ─── All-Letters mode ───────────────────────────────────────────────────── */

/* Invalid letter key: white background, gray text, outlined — "inverted" */
.key-invalid-letter {
  background: #fff !important;
  color: var(--gray-dark) !important;
  border: 2px solid var(--gray-light) !important;
  font-size: 0.72rem;
}

/* Subtle override: don't let tile-state colors bleed through on invalid keys
   (they haven't been guessed in the subset context so keep them "inverted neutral") */
.key-invalid-letter.key-absent,
.key-invalid-letter.key-unused {
  background: #fff !important;
  color: var(--gray-dark) !important;
}

/* Daily puzzle type badge */
.type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 3px;
  vertical-align: middle;
}
.type-daily {
  background: #1a6a9a;
  color: #fff;
}

/* Resume page */
.resume-intro { font-size: 0.9rem; color: var(--gray-mid); margin-bottom: 12px; }
.resume-form { margin-top: 10px; }
.resume-btn { font-size: 0.88rem; padding: 8px 18px; }

/* Mode badges (Standard / All Letters) */
.mode-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
  vertical-align: middle;
}

.mode-standard {
  background: var(--gray-light);
  color: var(--gray-mid);
}

.mode-all {
  background: #3d7a3d;
  color: #fff;
}

/* Mode badge in the game-info bar */
.game-badge .mode-badge {
  font-size: 0.65rem;
}

/* All-Letters toggle in the selection modal */
.modal-all-letters-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  cursor: pointer;
  user-select: none;
}

.modal-all-letters-toggle {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.modal-all-letters-toggle input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.modal-toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: var(--gray-light);
  border-radius: 10px;
  transition: background 0.2s;
  position: relative;
}

.modal-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}

.modal-all-letters-toggle input:checked + .modal-toggle-track {
  background: #3d7a3d;
}

.modal-all-letters-toggle input:checked + .modal-toggle-track::after {
  left: 19px;
}

.modal-all-letters-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-dark);
}

.modal-all-letters-hint {
  font-size: 0.75rem;
  color: var(--gray-mid);
}

/* ─── Home screen ─────────────────────────────────────────────────────────── */

.home-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding: 16px;
}

.home-section {
  margin-bottom: 14px;
}

.home-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gray-mid);
  margin-bottom: 6px;
}

.home-card-daily,
.home-card-quick,
.home-card-choose,
.home-card-resume {
  position: relative;
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: 10px;
  padding: 18px 20px 16px;
}

.hc-completed-msg {
  margin-top: 14px;
  padding: 10px;
  text-align: center;
  background: #eaf4ea;
  border: 2px solid #3d7a3d;
  border-radius: 8px;
  color: #3d7a3d;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.home-card-daily {
  border-color: var(--blue);
}

.hc-direction {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-mid);
  margin-bottom: 10px;
}

.hc-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.hc-range-letter {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--blue-dark);
  line-height: 1;
  min-width: 26px;
}

.hc-range-line {
  flex: 1;
  height: 3px;
  background: var(--gray-light);
  border-radius: 2px;
}

.hc-detail {
  font-size: 0.82rem;
  color: var(--gray-mid);
  margin-bottom: 12px;
}

.hc-tiles {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 12px;
}

.hc-range-badge {
  flex: 1;
  text-align: center;
}

.hc-tile {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--blue);
  flex-shrink: 0;
}

.hc-badge-row {
  margin-bottom: 10px;
}

.hc-all-letters-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 2px;
  cursor: pointer;
  user-select: none;
}

.hc-all-letters-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-dark);
}

.hc-all-letters-hint {
  font-size: 0.75rem;
  color: var(--gray-mid);
}

.hc-play-btn {
  margin-top: 14px !important;
}

.hc-choose-desc {
  font-size: 0.85rem;
  color: var(--gray-mid);
  margin-bottom: 4px;
}

.hc-choose-btn {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* ── Choose Limits panel ── */
.custom-range-panel {
  padding: 8px 0 4px;
}

.custom-range-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.custom-range-letter {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--blue-dark);
  min-width: 28px;
  text-align: center;
  line-height: 1;
}

.custom-range-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-mid);
  letter-spacing: 0.04em;
}

/* Dual-handle range slider */
.dual-range-wrap {
  position: relative;
  height: 36px;
  margin: 4px 0 2px;
}

.dual-range-track {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  right: 0;
  height: 6px;
  background: var(--gray-light);
  border-radius: 3px;
  pointer-events: none;
}

.dual-range-fill {
  position: absolute;
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
}

.dual-range-input {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  width: 100%;
  height: 6px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
  outline: none;
}

.dual-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
  pointer-events: all;
}

.dual-range-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
  pointer-events: all;
}

.dual-range-alphabet {
  display: flex;
  justify-content: space-between;
  margin: 2px 0 14px;
  padding: 0 2px;
}

.dual-alpha-tick {
  font-size: 0.62rem;
  color: var(--gray-light);
  font-weight: 600;
  letter-spacing: 0;
  transition: color 0.1s;
  user-select: none;
  line-height: 1;
}

.dual-alpha-tick.active {
  color: var(--blue);
}

.custom-options-label {
  font-size: 0.78rem;
  color: var(--gray-mid);
  margin-bottom: 8px;
  font-weight: 500;
}

.custom-option-card {
  cursor: pointer;
}
