/* Corporate Connections - Styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(to right,
    #ba81c5 0%,
    #ba81c5 calc(50% - 320px),
    #f9f6ef calc(50% - 320px),
    #f9f6ef calc(50% + 320px),
    #ba81c5 calc(50% + 320px),
    #ba81c5 100%
  );
  min-height: 100vh;
  padding: 20px;
  color: #1a1a1a;
}

header {
  text-align: center;
  margin-bottom: 24px;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
}

header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

header p.subtitle {
  font-size: 1.1rem;
  font-weight: 700;
  font-style: italic;
  color: #1a1a1a;
}

.puzzle-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.puzzle-nav button {
  background: none;
  border: 1px solid #888;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #111;
  transition: background 0.15s;
}

.puzzle-nav button:hover:not(:disabled) {
  background: #eee;
}

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

.game-container {
  width: 100%;
  max-width: 580px;
  box-sizing: border-box;
  margin: 0 auto;
}

.instruction {
  text-align: center;
  font-size: 0.95rem;
  margin-bottom: 16px;
  color: #333;
}

/* Solved groups appear above the grid */
.solved-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.solved-group {
  border-radius: 10px;
  padding: 14px 20px;
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.solved-group .group-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  margin-bottom: 4px;
}

.solved-group .group-words {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.tile {
  aspect-ratio: 1.2 / 1;
  background: #efece5;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  border: 2px solid transparent;
  transition: background 0.12s, transform 0.1s, border-color 0.12s;
  padding: 6px;
  line-height: 1.2;
  overflow-wrap: break-word;
  min-width: 0;
}

.tile:hover {
  background: #e2ded6;
}

.tile.selected {
  background: #5a5a5a;
  color: #fff;
  border-color: #5a5a5a;
}

.tile.shake {
  animation: shake 0.45s ease;
}

.tile.bounce {
  animation: bounce 0.4s ease;
}

/* Color themes */
.color-yellow  { background: #f9df6d; }
.color-green   { background: #a0c35a; }
.color-blue    { background: #b0c4ef; }
.color-purple  { background: #ba81c5; }

/* Mistakes */
.mistakes-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: #444;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #999;
  display: inline-block;
  transition: background 0.3s, transform 0.3s;
}

.dot.used {
  background: #e8e8e8;
  transform: scale(0.8);
}

/* Buttons */
.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 2px solid #333;
  background: transparent;
  border-radius: 100px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: #333;
}

.btn:hover:not(:disabled) {
  background: #333;
  color: #fff;
}

.btn:disabled {
  border-color: #ccc;
  color: #ccc;
  cursor: default;
}

.btn.btn-primary {
  background: #333;
  color: #fff;
  border-color: #333;
}

.btn.btn-primary:hover:not(:disabled) {
  background: #111;
  border-color: #111;
}

/* Toast / message */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 22px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* One away indicator */
.toast.one-away {
  background: #6a5acd;
}

/* Win / lose screen */
.end-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.end-screen.visible {
  display: flex;
}

.end-screen h2 {
  font-size: 1.6rem;
  font-weight: 800;
}

.end-screen p {
  color: #555;
  font-size: 0.95rem;
}

.share-result {
  font-family: monospace;
  background: #f0ece4;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1.2rem;
  letter-spacing: 2px;
  line-height: 1.6;
  text-align: center;
}

.end-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-invite {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.btn-invite:hover {
  background: #333 !important;
  border-color: #333 !important;
  color: #fff !important;
}

/* ── Mid-game nudge ─────────────────────────────────────────────────────── */

.mid-nudge {
  display: none;
  background: #1a1a1a;
  color: #f5f0e8;
  border-radius: 12px;
  padding: 14px 40px 14px 16px;
  margin-bottom: 12px;
  position: relative;
  animation: fadeIn 0.4s ease;
}

.mid-nudge.visible {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.mid-nudge-text {
  flex: 1;
  min-width: 0;
}

.mid-nudge-main {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f5f0e8;
  margin-bottom: 4px;
}

.mid-nudge-aside {
  font-size: 0.78rem;
  color: #b0a898;
  line-height: 1.5;
}

.mid-nudge-aside .aside {
  opacity: 0.8;
}

.mid-nudge-btn {
  border-color: #f5f0e8;
  color: #f5f0e8;
  white-space: nowrap;
  font-size: 0.82rem;
  padding: 8px 16px;
  flex-shrink: 0;
}

.mid-nudge-btn:hover:not(:disabled) {
  background: #f5f0e8;
  color: #1a1a1a;
}

.mid-nudge-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: #666;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
  line-height: 1;
}

.mid-nudge-close:hover {
  color: #f5f0e8;
}

/* ── Invite overlay ──────────────────────────────────────────────────────── */

.invite-screen {
  position: fixed;
  inset: 0;
  background: #0f0f0f;
  color: #f5f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  padding: 40px 20px;
}

.invite-screen.open {
  opacity: 1;
  pointer-events: all;
}

.invite-inner {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 40px;
  animation: fadeInUp 0.5s ease both;
}

.invite-back {
  background: none;
  border: none;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: color 0.15s;
  align-self: flex-start;
}

.invite-back:hover {
  color: #f5f0e8;
}

.invite-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.invite-eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #888;
}

.invite-headline {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #f5f0e8;
}

.invite-body {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #b0a898;
  max-width: 420px;
}

/* Form */
.invite-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.invite-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invite-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
}

.invite-field input,
.invite-field textarea {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  color: #f5f0e8;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
  outline: none;
}

.invite-field input::placeholder,
.invite-field textarea::placeholder {
  color: #555;
}

.invite-field input:focus,
.invite-field textarea:focus {
  border-color: #888;
}

.invite-field input.error,
.invite-field textarea.error {
  border-color: #e05050;
}

.btn-send {
  background: #f5f0e8;
  color: #0f0f0f;
  border: 2px solid #f5f0e8;
  border-radius: 100px;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  align-self: flex-start;
}

.btn-send:hover {
  background: #fff;
  border-color: #fff;
}

.invite-disclaimer {
  font-size: 0.75rem;
  color: #555;
  margin-top: -8px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Animations */
@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

@keyframes bounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(-10px); }
  60%  { transform: translateY(-4px); }
  80%  { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Responsive — fit full game on phone without scrolling */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  header {
    margin-bottom: 10px;
  }

  header h1 {
    font-size: 1.7rem;
  }

  header p.subtitle {
    font-size: 0.85rem;
  }

  .puzzle-nav {
    margin-bottom: 4px;
  }

  .instruction {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .solved-groups {
    gap: 5px;
    margin-bottom: 5px;
  }

  .solved-group {
    padding: 8px 12px;
  }

  .solved-group .group-words {
    font-size: 0.85rem;
  }

  .grid {
    gap: 6px;
    margin-bottom: 10px;
  }

  .tile {
    aspect-ratio: 1.4 / 1;
    font-size: 0.68rem;
    border-radius: 8px;
    padding: 4px;
  }

  .mistakes-row {
    margin-bottom: 10px;
    font-size: 0.82rem;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .invite-screen {
    padding: 16px;
    align-items: flex-start;
  }

  .invite-inner {
    gap: 24px;
  }

  .invite-body {
    font-size: 0.95rem;
    max-width: 100%;
  }

  .invite-field input,
  .invite-field textarea {
    font-size: 0.95rem;
    padding: 10px 12px;
  }

  .btn-send {
    width: 100%;
    text-align: center;
  }
}
