:root {
  color-scheme: light;
  --bg-top: #6ee7f5;
  --bg-bottom: #a78bfa;
  --tile-bg: #ffffff;
  --tile-shadow: rgba(0, 0, 0, 0.15);
  --text: #1f2937;
  --accent: #f97316;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  text-align: center;
}

h1 {
  font-size: 2.2rem;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  margin-bottom: 32px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px;
}

.tile {
  aspect-ratio: 1 / 1;
  background: var(--tile-bg);
  border: none;
  border-radius: 20px;
  box-shadow: 0 6px 16px var(--tile-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}

.tile:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 10px 22px var(--tile-shadow);
}

.tile:disabled {
  opacity: 0.5;
  cursor: default;
}

.tile-emoji {
  font-size: 2.4rem;
}

.tile-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px #fff;
}

.hidden { display: none !important; }

/* --- Chat overlay --- */

.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-panel {
  width: 100%;
  max-width: 480px;
  height: min(640px, 90vh);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}

.chat-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.35;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble.pending {
  opacity: 0.6;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
}

.chat-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
}

.chat-form button {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.chat-form button:disabled {
  opacity: 0.5;
  cursor: default;
}

.chat-error {
  min-height: 1.2em;
  margin: 0 16px 10px;
  color: #dc2626;
  font-size: 0.85rem;
}
