/* =====================
   Reset & Base
   ===================== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(-45deg, var(--bg-1), var(--bg-2), var(--bg-3), var(--bg-4));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: #222;
}

@keyframes gradientBG {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* =====================
   Layout
   ===================== */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* =====================
   Header
   ===================== */
.app-header {
  text-align: center;
  padding: 24px 0 8px;
}

.app-header .logo {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 4px;
}

.app-header h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  color: #333;
  letter-spacing: 0.5px;
  font-family: 'Bungee', sans-serif;
}

.app-header .tagline {
  font-size: 14px;
  color: #666;
  margin: 4px 0 0;
}

/* =====================
   Cards (screens)
   ===================== */
.card {
  background: #fff;
  border-radius: 20px;
  padding: 24px 20px;
  margin-top: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 20px;
  color: #222;
  text-align: center;
}

/* =====================
   Input groups
   ===================== */
.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  font-size: 16px; /* min 16px prevents iOS zoom */
  padding: 13px 14px;
  border: 1.5px solid #ddd;
  border-radius: 12px;
  outline: none;
  background: #fafafa;
  color: #222;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
select:focus {
  border-color: #7F77DD;
  box-shadow: 0 0 0 3px rgba(127,119,221,0.18);
  background: #fff;
}

input[type="text"]::placeholder {
  color: #aaa;
}

/* =====================
   Buttons
   ===================== */
.btn {
  display: block;
  width: 100%;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: filter 0.15s, transform 0.1s;
  margin-top: 8px;
  -webkit-appearance: none;
}

.btn:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

.btn-primary {
  background: #7F77DD;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-success {
  background: #28a745;
  color: #fff;
}

.btn-success:hover {
  filter: brightness(1.08);
}

.btn-warning {
  background: #fd7e14;
  color: #fff;
}

/* Link buton */
.link-btn {
  background: none;
  border: none;
  color: #7F77DD;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* =====================
   Divider
   ===================== */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
  color: #bbb;
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #eee;
}

.switch-hint {
  text-align: center;
  font-size: 14px;
  color: #666;
  margin: 0;
}

/* =====================
   Player list
   ===================== */
.player-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  border: 1.5px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  background: #fafafa;
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.player-list li {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-list li:last-child {
  border-bottom: none;
}

.player-list li::before {
  content: '';
  display: none;
}

/* =====================
   Time selector
   ===================== */
.time-selector {
  margin-bottom: 16px;
}

.time-selector label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #888;
}

/* =====================
   Waiting text
   ===================== */
.waiting-text {
  text-align: center;
  font-size: 14px;
  color: #888;
  font-style: italic;
  margin: 8px 0;
}

/* =====================
   Game screen
   ===================== */
.question-header {
  text-align: center;
  margin-bottom: 16px;
}

.question-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #7F77DD;
  background: rgba(127,119,221,0.1);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

#question-title {
  font-size: 26px;
  font-weight: 800;
  color: #222;
  margin: 0;
}

/* Timer */
.timer-wrapper {
  width: 100%;
  height: 10px;
  background: #eee;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: #4caf50;
  border-radius: 99px;
  transition: width 0.9s linear, background-color 0.5s;
}

.progress-text {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-bottom: 18px;
}

/* Answer area */
.answer-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-area input {
  font-size: 16px;
  padding: 14px;
}

/* =====================
   Story list (results)
   ===================== */
.story-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.story-list li {
  background: #f0edff;
  border-left: 4px solid #7F77DD;
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.5;
  color: #333;
  animation: fadeInUp 0.4s ease;
}

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

/* Tema satırı */
.theme-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* =====================
   Lobi odalar listesi
   ===================== */
.lobby-section {
  margin-top: 16px;
  border-top: 1.5px solid #f0f0f0;
  padding-top: 14px;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #555;
}

.room-count {
  font-size: 12px;
  background: #f0edff;
  color: #7F77DD;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 600;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.no-rooms {
  text-align: center;
  color: #aaa;
  font-size: 14px;
  font-style: italic;
  margin: 8px 0;
  line-height: 1.8;
}

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f7ff;
  border: 1.5px solid #e0deff;
  border-radius: 12px;
  padding: 12px 14px;
  gap: 10px;
}

.room-card-info {
  flex: 1;
}

.room-card-name {
  font-weight: 700;
  font-size: 15px;
  color: #222;
}

.room-card-meta {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.room-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.status-lobby { background: #d4edda; color: #155724; }
.status-playing { background: #fff3cd; color: #856404; }

.room-join-btn {
  background: #7F77DD;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s;
}

.room-join-btn:hover { filter: brightness(1.1); }
.room-join-btn:disabled { background: #ccc; cursor: not-allowed; }

/* =====================
   Ana ekran iki buton
   ===================== */
.home-btn-row {
  display: flex;
  gap: 12px;
}

.home-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 10px;
  font-size: 15px;
  border-radius: 16px;
}

.home-btn span {
  font-size: 14px;
  font-weight: 700;
}

.btn-join {
  background: #28a745;
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.btn-join:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

.btn-how {
  background: rgba(127,119,221,0.12);
  color: #7F77DD;
  border: 1.5px solid #7F77DD;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px;
  width: 100%;
  margin-top: 10px;
  font-size: 15px;
  transition: background 0.2s;
}

.btn-how:hover {
  background: rgba(127,119,221,0.2);
}

/* Nasıl Oynanır adımları */
.how-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.how-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #f8f7ff;
  border-radius: 12px;
  padding: 14px;
}

.how-icon {
  min-width: 36px;
  height: 36px;
  background: #7F77DD;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.how-text strong {
  display: block;
  font-size: 15px;
  color: #222;
  margin-bottom: 4px;
}

.how-text p {
  font-size: 13px;
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* Geri butonu */
.back-btn {
  background: none;
  border: none;
  color: #7F77DD;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 12px;
  display: block;
}

/* =====================
   Geri bildirim butonu
   ===================== */
.feedback-bar {
  text-align: center;
  margin-top: 16px;
  padding-bottom: 16px;
}

.feedback-btn {
  display: inline-block;
  background: rgba(255,255,255,0.7);
  color: #555;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 99px;
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

.feedback-btn:hover {
  background: rgba(255,255,255,0.9);
}

/* =====================
   Watermark arka plan
   ===================== */
.watermark-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  mix-blend-mode: overlay;
}

.watermark-bg::before {
  content: '';
  position: absolute;
  top: -100%;
  left: -100%;
  width: 400%;
  height: 400%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='120'%3E%3Ctext x='50%25' y='50%25' dominant-baseline='middle' text-anchor='middle' font-family='Georgia, serif' font-size='18' font-style='italic' font-weight='normal' letter-spacing='2' fill='rgba(255,255,255,0.25)' transform='rotate(-25, 130, 60)'%3EAbsurdStory%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 240px 120px;
}

.container {
  position: relative;
  z-index: 1;
}

/* =====================
   Slogan animasyonu
   ===================== */
.tagline {
  transition: opacity 0.4s ease;
}

/* =====================
   Yardım butonu ve paneli
   ===================== */
.answer-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.answer-btn-row #submitBtn {
  flex: 1;
  margin-top: 0;
}

.answer-btn-row #helpBtn {
  flex: 0 0 auto;
  margin-top: 0;
}

.btn-help {
  background: #fff3cd;
  color: #856404;
  border: 1.5px solid #ffc107;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 14px;
  flex: 0 0 auto;
  white-space: nowrap;
  width: auto;
}

.help-panel {
  background: #f8f7ff;
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
  border: 1.5px solid #e0deff;
}

.help-title {
  font-weight: 700;
  font-size: 14px;
  color: #555;
  margin: 0 0 10px;
}

.quick-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestion-chip {
  background: #fff;
  border: 1.5px solid #7F77DD;
  color: #7F77DD;
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.suggestion-chip:hover {
  background: #7F77DD;
  color: #fff;
}

.btn-ai {
  background: linear-gradient(135deg, #7F77DD, #fda085);
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px;
  width: 100%;
  font-size: 15px;
  margin-top: 4px;
}

.ai-suggestion {
  margin-top: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  color: #333;
  border: 1.5px solid #e0deff;
  line-height: 1.6;
}

/* =====================
   Alt bar (copyright + feedback)
   ===================== */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 20px;
  margin-top: 8px;
}

.copyright {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

.feedback-btn {
  display: inline-block;
  background: rgba(255,255,255,0.7);
  color: #555;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 99px;
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

.feedback-btn:hover {
  background: rgba(255,255,255,0.9);
}

/* Alt yasal linkler */
.legal-links {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  padding-bottom: 10px;
}

.legal-links a {
  color: rgba(255,255,255,0.7);
  text-decoration: underline;
}

.legal-links a:hover {
  color: rgba(255,255,255,0.95);
}

.legal-links span {
  margin: 0 6px;
  color: rgba(255,255,255,0.4);
}

.mute-btn {
  background: rgba(255,255,255,0.7);
  border: none;
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

.mute-btn:hover {
  background: rgba(255,255,255,0.9);
}

/* =====================
   Renk Temaları
   ===================== */
body {
  --accent: #7F77DD;
  --accent-light: rgba(127,119,221,0.12);
  --bg-1: #ffecd2;
  --bg-2: #fcb69f;
  --bg-3: #f6d365;
  --bg-4: #fda085;
}

body.theme-gece {
  --accent: #9b8fd4;
  --accent-light: rgba(155,143,212,0.15);
  --bg-1: #1a1a2e;
  --bg-2: #16213e;
  --bg-3: #0f3460;
  --bg-4: #533483;
}

body.theme-okyanus {
  --accent: #0077b6;
  --accent-light: rgba(0,119,182,0.12);
  --bg-1: #caf0f8;
  --bg-2: #90e0ef;
  --bg-3: #00b4d8;
  --bg-4: #0077b6;
}

body.theme-orman {
  --accent: #2d6a4f;
  --accent-light: rgba(45,106,79,0.12);
  --bg-1: #d8f3dc;
  --bg-2: #b7e4c7;
  --bg-3: #74c69d;
  --bg-4: #2d6a4f;
}

body.theme-gece .card {
  background: #1e1e3f;
  color: #eee;
}

body.theme-gece input[type="text"],
body.theme-gece select {
  background: #2a2a4a;
  color: #eee;
  border-color: #444;
}

body.theme-gece .card h2,
body.theme-gece #question-title,
body.theme-gece .how-text strong,
body.theme-gece .question-label,
body.theme-gece .waiting-text,
body.theme-gece .app-header h1,
body.theme-gece .app-header .tagline,
body.theme-gece .lobby-header,
body.theme-gece .room-card-name { color: #eee; }

body.theme-gece .player-list {
  background: #2a2a4a;
  border-color: #444;
}

body.theme-gece .player-list li {
  color: #eee;
  border-color: #333;
}

body.theme-gece .story-list li {
  background: #2a2a4a;
  color: #eee;
}

/* Tema satırı */
.theme-row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 12px;
  flex-wrap: nowrap;
}

/* Tema butonları */
.theme-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.theme-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid #ddd;
  border-radius: 50%;
  background: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-btn.active {
  border-color: var(--accent, #7F77DD);
  background: var(--accent-light, rgba(127,119,221,0.12));
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* =====================
   Yükleme Ekranı
   ===================== */
#loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #7F77DD, #fda085);
  background-image: url('/loading-bg.jpg');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s ease;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-logo {
  font-size: 80px;
  animation: logoBounce 0.8s ease infinite alternate;
}

@keyframes logoBounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-20px) scale(1.1); }
}

.loading-title {
  font-family: 'Bungee', sans-serif;
  font-size: 36px;
  color: white;
  margin-top: 16px;
  letter-spacing: 2px;
}

.loading-dots {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  animation: dotPulse 1.2s ease infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* =====================
   Avatar Seçici
   ===================== */
.avatar-picker {
  margin-bottom: 14px;
}

.avatar-picker label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
  display: block;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.avatar-btn {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 2px;
  cursor: pointer;
  transition: all 0.15s;
  aspect-ratio: 1;
  overflow: hidden;
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  pointer-events: none;
  display: block;
}

.avatar-btn.active {
  border-color: #7F77DD;
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(127,119,221,0.4);
}

.avatar-btn:hover {
  transform: scale(1.05);
  border-color: #7F77DD;
}

/* =====================
   Oyuncu Varlık Paneli
   ===================== */
#player-presence {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  z-index: 100;
  max-width: 90vw;
  margin: 0 auto 12px auto;
  padding: 6px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 99px;
  backdrop-filter: blur(6px);
  position: relative;
}

.presence-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  overflow: hidden;
  position: relative;
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}

.presence-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.presence-avatar .check {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 14px;
  height: 14px;
  background: #4caf50;
  border-radius: 50%;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  border: 1.5px solid white;
  opacity: 0;
  transition: opacity 0.3s;
}

.presence-avatar.answered {
  border-color: #4caf50;
}

.presence-avatar.answered .check {
  opacity: 1;
}

.presence-avatar .name-tip {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.presence-avatar:hover .name-tip {
  opacity: 1;
}

.presence-avatar:hover {
  transform: scale(1.1);
}

/* =====================
   Tablet & Desktop
   ===================== */
@media (min-width: 600px) {
  .container {
    padding: 24px 0 60px;
  }

  .app-header {
    padding-top: 40px;
  }

  .card {
    padding: 32px 32px;
  }
}

/* =====================
   Safe area (notch/home bar)
   ===================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}