/*=============================================
=            GLOBAL & RESET STYLES            =
=============================================*/

/* Import a clean modern font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {

    --accent: #2AB7CA;          /* Mediterranean Sea */
  --accent-light: #B3ECF0;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #333333;
  --muted: #777777;
  --shadow: rgba(0, 0, 0, 0.1);
  --success: #10B981;
  --error: #EF4444;
}

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



body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.screen {
  display: none;
  padding: 2rem;
}
.screen.active {
  display: block;
}

/* Utility containers */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/*=============================================
=            TYPOGRAPHY & BUTTONS             =
=============================================*/

.rap_app  {
  font-weight: 600;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.rap_app .cover {
  width: 40rem;
}

.start{
  display: flex;
  flex-direction: column;
  align-items: center;
}

.start h1{
  font-size: 5rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.start img{
  margin-bottom: 20px;
}

.big-btn {
  display: inline-block;
  background-color: rgb(255, 132, 17);
  color: #fff;
  font-size: 2rem;
  font-weight: 900;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.big-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow);
}

.skill{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}


.skill h2{
  font-size: 2.5rem;
}

.skill input{
  font-size: 1.4rem;
  margin-bottom: 20px;
}

.skill h3{
  font-size: 2rem;
}

.skill li{
  font-size: 1.5rem !important;
}

/*=============================================
=            ROUND INDICATOR & PROG           =
=============================================*/

.round-indicator {
  color: var(--accent);
  margin-bottom: 1rem;
}

.progress-bar {
  width: 80%;
  height: 12px;
  background: var(--accent-light);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem auto;
}
#q-progress {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

/*=============================================
=            SKILL SELECTION STYLES           =
=============================================*/

#skills-list {
 display: flex;
 flex-direction: column;
}

.skill-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--shadow);
  padding: 1rem;
  text-align: left;
  transition: transform 0.2s;
}
.skill-card:hover {
  transform: translateY(-4px);
}

.skill-card h3 {
  margin-bottom: 0.5rem;
}

.grade-list {
  list-style: none;
  margin-top: 0.5rem;
}
.grade-list li {
  display: inline-block;
  margin: 0.3rem;
  padding: 0.4rem 0.8rem;
  background: var(--accent-light);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.grade-list li:hover {
  background: var(--accent);
  color: #fff;
}

/*=============================================
=            QUESTION SCREEN STYLES           =
=============================================*/

#questions {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.question {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--shadow);
  padding: 1rem;
  text-align: left;
  width: 80%;
}

.question p {
  margin-bottom: 1rem;
  font-weight: 500;
  font-size: 3rem;
}

.options button {
  display: block;
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.6rem;
  background: var(--accent-light);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 2rem;
  transition: background 0.2s;
  font-weight: 400;
}
.options button:hover {
  background: var(--accent);
  color: #fff;
}
.options button.correct {
  background: var(--success) !important;
  color: #fff;
}
.options button.wrong {
  background: var(--error) !important;
  color: #fff;
}

/*=============================================
=            PUZZLE SCREEN STYLES             =
=============================================*/

.puzzle{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#difficulty-controls {
  margin-bottom: 1.5rem;
}
.difficulty {
  margin: 0.3rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.difficulty:hover {
  transform: translateY(-2px);
}

.difficulty.active,
.difficulty:hover {
  background: var(--accent);
  color: #fff;
}

#board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
#puzzle-wrap {
  position: relative;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 2 / 1;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 24px var(--shadow);
}

/* only stretch the two overlay canvases */
#ghost,
#hint {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}


#ghost {
  opacity: 0.2;
  pointer-events: none;
}
#hint {
  pointer-events: none;
}

#pieces-area {
  position: relative;
  width: 800px;
  min-height: 200px;
  background: var(--surface);
  border: 2px dashed var(--accent-light);
  border-radius: 12px;
  box-shadow: inset 0 4px 12px var(--shadow);
}

/* Toast */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(51, 51, 51, 0.9);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
}

/* Puzzle pieces */
.piece {
  position: absolute;
  cursor: grab;
  user-select: none;
  border: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.3s;
  z-index: 20; /* unlocked on top */
}

/* touch: avoid page scroll while dragging pieces */
#puzzle-wrap, .piece { touch-action: none; }


/* lifted look while finger-dragging on mobile/tablet */
.piece.lifted {
  transform: scale(1.06);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}
.piece.lifted::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 10px;
  background: radial-gradient(closest-side, rgba(255,255,255,.35), transparent 70%);
  pointer-events: none;
}

/* darker solid border on unlocked */
.piece:not(.locked) {
  border-color: #8bac2b;
}
.piece.locked {
  border: none;
  box-shadow: none;
  cursor: default;
  z-index: 10; /* locked underneath unlocked */
}

/* stacking + no scroll-jank + lift effect */
#puzzle-wrap { position: relative; }

#ghost, #hint {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* pieces can be tapped through the canvases */
  z-index: 1;             /* under the pieces */
}

.piece {
  position: absolute;
  z-index: 5;             /* above ghost/hint */
  touch-action: none;     /* stop page scroll during drag on touch */
}

.piece.lifted {
  transform: scale(1.06);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
  z-index: 9999;          /* top while moving */
}

.piece.lifted::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 10px;
  background: radial-gradient(closest-side, rgba(255,255,255,.35), transparent 70%);
  pointer-events: none;
}


/* Glow animation */
@keyframes glowPulse {
  0%   { box-shadow: 0 0 8px var(--accent); }
  50%  { box-shadow: 0 0 24px var(--accent); }
  100% { box-shadow: 0 0 8px var(--accent); }
}
.piece.glow {
  animation: glowPulse 1s ease-in-out infinite;
}

/* Completion Modal */
/* Completion Modal as stylish bottom sheet */
#modal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
  font-size: 1.6rem;
}
#modal.hidden {
  display: none;
}
#modal-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: 20px 20px 0 0;
  text-align: center;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 -4px 20px var(--shadow);
  animation: slideUp 0.4s ease-out;
}
#modal-content h2 {
  margin-bottom: 1.5rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
#modal-content button {
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  padding: 12px 30px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  transition: background 0.2s, transform 0.2s;
}
#modal-content button:hover {
  background: #2395a6;
  transform: translateY(-2px);
}

/* Slide up animation */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.name-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.name-modal {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  position: relative;
  width: 90%;
  max-width: 320px;
  text-align: center;
}
.name-modal .close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  cursor: pointer;
}
.name-modal input {
  width: 100%;
  padding: 0.75rem;
  margin: 1rem 0;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.name-modal button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  background: #8254EA;
  color: #fff;
  cursor: pointer;
}
.name-modal button:disabled {
  opacity: 0.5;
  cursor: default;
}

.name-backdrop {
  position: fixed;
  top:0; left:0; right:0; bottom:0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.name-dialog {
  background: #fff;
  padding: 2em;
  border-radius: 8px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}
.name-dialog input {
  width: 100%;
  padding: 0.5em;
  margin: 1em 0;
  font-size: 1em;
}
.name-dialog button {
  padding: 0.6em 1.2em;
  font-size: 1em;
  cursor: pointer;
}


.gameover{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
/* Game Over */
#gameover-screen h2 {
  margin-bottom: 1.5rem;
  font-size: 3rem;
  margin-top: 100px;
  margin-bottom: 50px;
}

/*=============================================
=            RESPONSIVE MEDIA QUERIES         =
=============================================*/

/* 1) Large desktops / wide screens */
@media (max-width: 1200px) {
  /* Puzzle area */
  #puzzle-wrap {
    width: 90%;
    height: 350px;
  }
  #pieces-area {
    width: 90%;
    min-height: 180px;
  }
  /* Question cards */
  .question {
    width: 70%;
  }
}

/* 2) Desktops / tablets landscape */
@media (max-width: 992px) {
  /* General container paddings */
  body {
    padding: 1rem;
  }
  /* Start screen cover */
  .rap_app .cover {
    width: 30rem;
  }
  .start h1 {
    font-size: 4rem;
  }
  .big-btn {
    font-size: 1.8rem;
    padding: 0.6rem 1.5rem;
  }
  /* Skill screen grid */
  #skills-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  /* Question screen */
  .question {
    width: 80%;
  }
  .question p {
    font-size: 2.5rem;
  }
  .options button {
    font-size: 1.6rem;
    padding: 0.5rem;
  }
  /* Puzzle screen */
  #puzzle-wrap {
    height: 300px;
  }
  #pieces-area {
    min-height: 160px;
  }
  .difficulty {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
}

/* 3) Tablets / small desktops / large phones */
@media (max-width: 768px) {
  /* Start screen & cover */
  .rap_app .cover {
    width: 100%;
    max-width: 28rem;
  }
  .start h1 {
    font-size: 3rem;
  }
  .big-btn {
    font-size: 1.4rem;
    padding: 0.5rem 1.2rem;
  }
  /* Skill screen typography */
  .skill h2 {
    font-size: 2rem;
  }
  .skill input {
    font-size: 1.2rem;
  }
  .skill h3 {
    font-size: 1.7rem;
  }
  .skill li {
    font-size: 1.3rem !important;
  }
  /* Question screen layout */
  #questions {
    flex-direction: column;
    gap: 1rem;
  }
  .question {
    width: 100%;
    padding: 0.8rem;
  }
  .question p {
    font-size: 2rem;
  }
  .options button {
    font-size: 1.4rem;
  }
  /* Puzzle area */
  #puzzle-wrap {
    width: 100%;
    height: 250px;
  }
  #pieces-area {
    width: 100%;
    min-height: 140px;
  }
}

/* 4) Mobile phones */
@media (max-width: 576px) {
  /* Body padding */
  body {
    padding: 0.5rem;
  }
  /* Start screen */
  .start h1 {
    font-size: 2.5rem;
  }
  .big-btn {
    width: 100%;
    font-size: 1.2rem;
    padding: 0.5rem;
  }
  /* Skill grid */
  #skills-list {
    grid-template-columns: 1fr;
  }
  .skill-card {
    padding: 0.8rem;
  }
  .grade-list li {
    font-size: 0.8rem;
    margin: 0.2rem;
  }
  /* Question screen */
  .question p {
    font-size: 1.8rem;
  }
  .options button {
    font-size: 1.2rem;
  }
  /* Puzzle screen */
  #puzzle-wrap {
    height: 200px;
  }
  #pieces-area {
    min-height: 120px;
  }
  .difficulty {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
  /* Modal bottom-sheet */
  #modal-content {
    padding: 1.5rem;
    max-width: 100%;
  }
  #modal-content h2 {
    font-size: 1.8rem;
  }
  #modal-content button {
    font-size: 1rem;
    padding: 10px 20px;
  }
  /* Game Over */
  #gameover-screen h2 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
  }
}
