/* ============================================================
   GuessUp – Stylesheet Cartoon  (landscape-first)
   ============================================================ */

/* ---------- Portrait Warning Overlay ---------- */
/* Instead of rotating, we show a nice "please rotate" screen */

/* ---------- CSS Variables ---------- */
:root {
  --purple:      #6C3FCB;
  --purple-dark: #4A2A9A;
  --purple-light:#9B6FE8;
  --yellow:      #FFD93D;
  --yellow-dark: #F4B400;
  --coral:       #FF6B6B;
  --coral-dark:  #E04444;
  --green:       #6BCB77;
  --green-dark:  #3DA64A;
  --red:         #FF4444;
  --red-dark:    #CC1111;
  --white:       #FFFFFF;
  --offwhite:    #F8F4FF;
  --text-dark:   #2D1B6B;
  --shadow:      rgba(45, 27, 107, 0.25);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(145deg, #6C3FCB 0%, #4A2A9A 50%, #2D1B6B 100%);
  color: var(--white);
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  transform: translateY(20px);
  -webkit-overflow-scrolling: touch;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
#screen-home {
  background: linear-gradient(165deg, #7B4FD4 0%, #4A2A9A 55%, #2A1870 100%);
  padding: 0 0 40px;
}

/* Decorative blobs */
.home-bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}
.blob1 { width: 300px; height: 300px; background: #FF6B6B; top: -80px; right: -80px; animation: blobFloat 8s ease-in-out infinite alternate; }
.blob2 { width: 250px; height: 250px; background: #FFD93D; bottom: 100px; left: -60px; animation: blobFloat 10s ease-in-out infinite alternate-reverse; }
.blob3 { width: 200px; height: 200px; background: #6BCB77; top: 40%; right: -40px; animation: blobFloat 12s ease-in-out infinite alternate; }

@keyframes blobFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(20px, 20px) scale(1.1); }
}

/* Header */
.home-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 20px 24px;
}
.logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.logo-emoji {
  font-size: 2.8rem;
  animation: wobble 2.5s ease-in-out infinite;
  display: inline-block;
}
.logo-title {
  font-family: 'Fredoka One', cursive;
  font-size: 3.2rem;
  letter-spacing: 1px;
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--yellow-dark), 0 0 30px rgba(255,217,61,0.4);
  line-height: 1;
}
.logo-sub {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
}

@keyframes wobble {
  0%,100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}

/* Main */
.home-main {
  position: relative;
  z-index: 1;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cards */
.card {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 8px 32px var(--shadow);
}

.card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--yellow);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.label-icon { font-size: 1.2rem; }

/* Theme input row */
.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.theme-input {
  flex: 1;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 2.5px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: var(--white);
  outline: none;
  transition: border-color 0.25s, background 0.25s;
}
.theme-input::placeholder { color: rgba(255,255,255,0.5); }
.theme-input:focus {
  border-color: var(--yellow);
  background: rgba(255,255,255,0.22);
}

/* Start button */
.btn-start {
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  background: var(--yellow);
  border-radius: var(--radius-md);
  padding: 0;
  box-shadow: 0 5px 0 var(--yellow-dark), 0 8px 20px rgba(255,217,61,0.4);
  transition: transform 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.btn-start:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--yellow-dark);
}
.btn-start-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: var(--text-dark);
  padding: 14px 22px;
}

/* Timer config */
.timer-config-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.timer-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}
.timer-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.timer-opt {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 50px;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
}
.timer-opt.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--text-dark);
  box-shadow: 0 3px 10px rgba(255,217,61,0.4);
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 27, 107, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.loading-overlay.hidden { display: none; }
.loading-spinner {
  width: 64px;
  height: 64px;
  border: 5px solid rgba(255,255,255,0.2);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--yellow);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* History */
.history-card { padding-bottom: 14px; }
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-empty {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.4);
  text-align: center;
  padding: 8px 0;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  border: 1.5px solid rgba(255,255,255,0.1);
}
.history-item:active { transform: scale(0.97); }
.history-item:hover { background: rgba(255,255,255,0.15); }
.history-emoji { font-size: 1.3rem; }
.history-info { flex: 1; }
.history-theme {
  font-weight: 800;
  font-size: 1rem;
  text-transform: capitalize;
}
.history-meta {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}
.history-play-btn {
  font-size: 1.2rem;
  opacity: 0.6;
}

/* ============================================================
   PERMISSION SCREEN
   ============================================================ */
#screen-permission {
  background: linear-gradient(165deg, #7B4FD4 0%, #4A2A9A 100%);
  align-items: center;
  justify-content: center;
}
.permission-content {
  text-align: center;
  padding: 32px 28px;
  max-width: 380px;
}
.perm-icon {
  font-size: 5rem;
  animation: phoneTilt 2s ease-in-out infinite alternate;
  display: block;
  margin-bottom: 20px;
}
@keyframes phoneTilt {
  from { transform: rotate(-20deg); }
  to   { transform: rotate(20deg); }
}
.perm-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--yellow);
  margin-bottom: 14px;
}
.perm-text {
  font-size: 1rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
  margin-bottom: 32px;
}
.btn-perm {
  display: block;
  width: 100%;
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--text-dark);
  background: var(--yellow);
  border: none;
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--yellow-dark), 0 10px 30px rgba(255,217,61,0.35);
  transition: transform 0.12s, box-shadow 0.12s;
  margin-bottom: 14px;
}
.btn-perm:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--yellow-dark); }
.btn-skip {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.6);
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-skip:hover { border-color: rgba(255,255,255,0.6); color: var(--white); }

/* ============================================================
   GAME SCREEN
   ============================================================ */
.game-screen {
  background: linear-gradient(165deg, #5A30B5 0%, #3A2090 100%);
  padding: 20px 20px 30px;
  justify-content: space-between;
  overflow: hidden;
}

/* Flash overlay */
.flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}
.flash-overlay.flash-green { background: rgba(107, 203, 119, 0.85); }
.flash-overlay.flash-red   { background: rgba(255, 68,  68,  0.85); }
.flash-overlay.visible     { opacity: 1; }

/* Result icon big */
.result-icon {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 210;
  font-size: 8rem;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}
.result-icon.hidden { display: none; }
@keyframes popIn {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Game top bar */
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Timer */
.timer-wrap {
  position: relative;
  width: 90px;
  height: 90px;
}
.timer-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg {
  fill: none;
  stroke: rgba(255,255,255,0.15);
  stroke-width: 8;
}
.timer-fg {
  fill: none;
  stroke: var(--yellow);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.29;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s;
}
.timer-fg.urgent { stroke: var(--coral); }
.timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.7rem;
  color: var(--white);
}

/* Score badges */
.score-badges {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.badge {
  font-family: 'Fredoka One', cursive;
  font-size: 1.2rem;
  padding: 8px 18px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.badge-found  { background: rgba(107,203,119,0.25); border: 2px solid var(--green); }
.badge-missed { background: rgba(255, 68, 68,0.2);  border: 2px solid var(--coral); }

/* Word area */
.word-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  padding: 20px 0;
}
.word-category {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.85;
}
.word-display {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(2.8rem, 10vw, 4.5rem);
  text-align: center;
  line-height: 1.15;
  color: var(--white);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  animation: wordEntrance 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 0 16px;
}
@keyframes wordEntrance {
  from { transform: scale(0.5) rotate(-5deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}
.word-hint {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
  font-weight: 600;
}

/* Tilt guide */
.tilt-guide {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.tilt-arrow {
  flex: 1;
  text-align: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  padding: 12px;
  border-radius: var(--radius-md);
  letter-spacing: 0.5px;
}
.tilt-up   { background: rgba(107,203,119,0.2); border: 2px solid var(--green);  color: var(--green); }
.tilt-down { background: rgba(255, 68, 68,0.15); border: 2px solid var(--coral); color: var(--coral); }

/* ============================================================
   SUMMARY SCREEN
   ============================================================ */
#screen-summary {
  background: linear-gradient(165deg, #7B4FD4 0%, #4A2A9A 100%);
  padding: 30px 20px 40px;
  align-items: center;
}

.summary-header {
  text-align: center;
  margin-bottom: 24px;
}
.summary-trophy {
  font-size: 4rem;
  display: block;
  animation: bounce 1s ease-in-out infinite alternate;
  margin-bottom: 8px;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-12px); }
}
.summary-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.9rem;
  color: var(--yellow);
}

/* Score boxes */
.summary-scores {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 24px;
}
.score-box {
  flex: 1;
  border-radius: var(--radius-lg);
  padding: 18px 10px;
  text-align: center;
  border: 2.5px solid;
}
.score-found  { background: rgba(107,203,119,0.2); border-color: var(--green); }
.score-missed { background: rgba(255, 68, 68,0.15); border-color: var(--coral); }
.score-box-num {
  display: block;
  font-family: 'Fredoka One', cursive;
  font-size: 3.2rem;
  line-height: 1;
}
.score-found  .score-box-num { color: var(--green); }
.score-missed .score-box-num { color: var(--coral); }
.score-box-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  display: block;
  margin-top: 4px;
}

/* Summary lists */
.summary-lists {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 28px;
}
.summary-col { flex: 1; }
.summary-col-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  margin-bottom: 10px;
}
.found-title { color: var(--green); }
.missed-title { color: var(--coral); }
.summary-word-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}
.summary-word-list li {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  text-transform: capitalize;
}
.found-list li  { background: rgba(107,203,119,0.2); color: var(--green); }
.missed-list li { background: rgba(255, 68, 68,0.15); color: var(--coral); }

/* Summary actions */
.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.btn-replay, .btn-home-summary {
  width: 100%;
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  padding: 18px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-replay {
  background: var(--yellow);
  color: var(--text-dark);
  box-shadow: 0 6px 0 var(--yellow-dark), 0 10px 30px rgba(255,217,61,0.35);
}
.btn-replay:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--yellow-dark); }
.btn-home-summary {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: none;
}
.btn-home-summary:active { transform: scale(0.97); }

/* ============================================================
   CALIBRATION OVERLAY
   ============================================================ */
.calib-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(45, 27, 107, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.calib-content {
  text-align: center;
  padding: 24px;
}
.calib-phone {
  font-size: 5rem;
  animation: phoneTilt 1.2s ease-in-out infinite alternate;
  display: block;
  margin-bottom: 16px;
}
.calib-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.6rem;
  color: var(--yellow);
  margin-bottom: 6px;
}
.calib-sub {
  font-size: 1rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 20px;
}
.calib-count {
  font-family: 'Fredoka One', cursive;
  font-size: 5rem;
  color: var(--white);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.15); opacity: 0.7; }
}

/* ============================================================
   PORTRAIT WARNING OVERLAY
   ============================================================ */
#portrait-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(145deg, #6C3FCB 0%, #4A2A9A 50%, #2D1B6B 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 20px;
}
#portrait-overlay.visible { display: flex; }

.portrait-phone {
  font-size: 6rem;
  display: block;
  animation: rotateHint 2s ease-in-out infinite;
  transform-origin: center;
}
@keyframes rotateHint {
  0%   { transform: rotate(0deg) scale(1); }
  40%  { transform: rotate(90deg) scale(1.1); }
  60%  { transform: rotate(90deg) scale(1.1); }
  100% { transform: rotate(0deg) scale(1); }
}

.portrait-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--yellow-dark);
}
.portrait-sub {
  font-size: 1rem;
  color: rgba(255,255,255,0.7);
  font-weight: 600;
  max-width: 280px;
  line-height: 1.5;
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }
