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

html, body {
  font-family: "Outfit", sans-serif;
  background: radial-gradient(circle at 50% 20%, #01213a 0%, #013b66 45%, #001627 100%);
  background-attachment: fixed;
  min-height: 100%;
  text-align: center;
  color: #f0f8ff;
  font-size: 18px;
  position: relative;
  overflow-x: hidden;
}

/* === VALGUSLAIGUD JA KÄRGMUSTER === */
body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(800px 400px at 30% 20%, rgba(0,200,255,0.25), transparent 70%),
    radial-gradient(900px 500px at 70% 80%, rgba(255,255,200,0.18), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0.8;
}

body::after {
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.3) 1px, transparent 1px),
    linear-gradient(30deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(150deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 50px 86px, 50px 86px, 50px 86px;
  mix-blend-mode: overlay;
  animation: hexmove 20s linear infinite;
}

@keyframes hexmove {
  0% { background-position: 0 0; opacity: 0.25; }
  50% { background-position: 25px 43px; opacity: 0.45; }
  100% { background-position: 0 0; opacity: 0.25; }
}

/* --- Jutumull --- */
.section { margin: 30px 0; }

.speech-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 40px;
  position: relative;
  z-index: 1;
}

.algus-bg {
  position: relative;
  display: inline-block;
  background: #f4ed9a;
  border: 4px solid #000;
  border-radius: 45px;
  padding: 35px 60px;
  min-height: 120px;
  max-width: 80%;
  animation: float 4s ease-in-out infinite;
  box-shadow: 6px 6px 0 #00000033;
  z-index: 2;
  color: #111;
}

.algus-bg h2 {
  font-size: 2.2rem;
  margin: 0;
  font-weight: 600;
}

.algus-bg.selgitus-mode { background: #fff; }

/* --- Mullid --- */
.algus-bg::before,
.algus-bg::after,
.algus-bg span {
  content: "";
  position: absolute;
  background: inherit;
  border: 4px solid #000;
  border-radius: 50%;
  transform-origin: center;
  animation: bubblePulse 3s ease-in-out infinite alternate;
}

.algus-bg::before {
  width: 32px; height: 32px;
  bottom: -25px; right: 20%;
  animation-delay: 0s;
}
.algus-bg::after {
  width: 20px; height: 20px;
  bottom: -50px; right: 15%;
  animation-delay: 0.8s;
}
.algus-bg span {
  width: 12px; height: 12px;
  bottom: -70px; right: 10%;
  animation-delay: 1.6s;
}

@keyframes bubblePulse {
  0% { transform: translateX(50%) scale(1); opacity: 1; }
  50% { transform: translateX(50%) scale(1.15); opacity: 0.9; }
  100% { transform: translateX(50%) scale(0.9); opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* === TEKSTIKASTID === */
#kasutajaTekst,
#abimaterjal {
  width: 90%;
  max-width: 600px;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  color: #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  backdrop-filter: blur(6px);
  resize: none;
  outline: none;
  margin-top: 30px;
  transition: all .3s ease;
  position: relative;
  z-index: 1;
  overflow-y: hidden;
}

#abimaterjal { height: 50px; margin-top: 40px; }

#kasutajaTekst:focus,
#abimaterjal:focus {
  border-color: #7fd4ff;
  box-shadow: 0 0 10px rgba(0,200,255,0.3);
  background: rgba(255,255,255,0.15);
}

#kasutajaTekst::placeholder,
#abimaterjal::placeholder {
  color: #cfeafb;
  opacity: 0.8;
  font-style: italic;

}

/* === NUPUD === */
.button-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 25px;
}

.btn {
  font-size: 1.1rem;
  padding: 14px 26px;
  border-radius: 12px;
  min-width: 160px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  background: #fff;
  color: #111;
  border: 2px solid #000;
}

.btn:hover {
  background: #f9f9f9;
  transform: translateY(-2px) scale(1.03);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.file-field input[type="file"] {
  position: absolute;
  left: -9999px;    /* peidame tehnilise inputi */
}


/* --- Hallid nupud --- */
#looNupudBtn, #looKoikNupudBtn, #looAIValikBtn, #abimaterjalValmisBtn, .file-field .btn {
  background: #fff;
  border: 2px solid #aaa;
  color: #111;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

#looNupudBtn:hover, #looKoikNupudBtn:hover, #looAIValikBtn:hover, #abimaterjalValmisBtn:hover {
  background: #f0f0f0;
}

/* --- Ülemine "Valmis" nupp --- */
#valmisBtn {
  background: #fff;
  border: 2px solid #aaa;
  color: #111;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
  font-size: 1.1rem;
  padding: 12px 28px;
}

#valmisBtn:hover { background: #f5f5f5; }

/* --- Õppimise roheline "Valmis" --- */
#koikBtn {
  background: #90ee90;
  border: 3px solid #000;
  color: #222;
  font-size: 1.3rem;
  font-weight: bold;
  padding: 14px 36px;
}

#koikBtn:hover { background: #80e080; }

/* --- Juhuslik sõna ja Korda samu sõnu --- */
#kergeBtn, #kordaBtn {
  font-size: 1.4rem;
  font-weight: bold;
  padding: 16px 42px;
  border-radius: 10px;
  background: #f4ed9a;
  border: 3px solid #000;
  color: #222;
}

#kergeBtn:hover, #kordaBtn:hover { background: #f0e77d; }

/* --- Selgitus ja Sisesta uued sõnad --- */
#selgitusBtn, #sisestaUuedBtn, #kontekstBtn {
  font-size: 1.4rem;
  font-weight: bold;
  padding: 16px 42px;
  border-radius: 10px;
  background: #fff;
  border: 3px solid #000;
  color: #222;
}

#selgitusBtn:hover, #sisestaUuedBtn:hover, #kontekstBtn:hover { background: #f5f5f5; }

/* --- Taimer --- */
#container.timer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#display {
  font-size: 2.2rem;
  font-weight: bold;
  color: #ffffff;
  width: 130px;
  text-align: center;
  margin-bottom: 15px;
  border: none;
  background: none;
}

.timer-controls {
  display: flex;
  gap: 25px;
}

#startBtn, #stopBtn, #resetBtn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 60%;
  background-color: transparent;
  cursor: pointer;
}

#startBtn { background-image: url('play.png'); }
#stopBtn  { background-image: url('stop.png'); }
#resetBtn { background-image: url('rewind.png'); }

/* --- Sõnanuppude konteiner --- */
#sonadeValik {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
}

.Wordsbtn {
  padding: 8px 10px;
  margin: 0;
  border: 1px solid #ccc;
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  color: #000;
}

.Wordsbtn:hover { background: #f0f0f0; }

.Wordsbtn.valitud {
  background: #90ee90;
  font-weight: bold;
}

/* --- Tekstialad ja asetus --- */
#vahe {
  display: block;
  text-align: center;
  margin-top: 40px;
}

#kasutajaTekst {
  width: 80%;
  max-width: 600px;
  height: 160px;
  margin: 20px auto;
  display: block;
}

/* --- Otsas nuppude paigutus --- */
#kordaBtn, #sisestaUuedBtn {
  margin: 12px 8px;
}

.ai-slider-wrap {
  position: relative;
  display: inline-block;
  text-align: center;
  background: #fffbea;
  border: 4px solid #000;
  border-radius: 35px;
  padding: 28px 40px;
  margin-top: 20px;
  box-shadow: 6px 6px 0 #0003;
  width: 80%;
  max-width: 600px;
  min-width: 280px;
  transition: width 0.3s ease;
}

/* Muudab laiuse sujuvalt vastavalt ekraani laiusel */
@media (max-width: 768px) {
  .ai-slider-wrap {
    width: 90%;
    padding: 20px;
  }
}

@media (min-width: 1200px) {
  .ai-slider-wrap {
    max-width: 720px;
  }
}

.ai-slider {
  width: 100%;
  accent-color: #f4ed9a;
  margin-top: 10px;
}

.ai-slider-value {
  margin-top: 10px;
  font-weight: bold;
  color: #000;
  font-size: 1.1rem;
}

.btn-ai-confirm {
  display: inline-block;
  background: #f4ed9a;
  color: #111;
  font-weight: 700;
  border: 3px solid #000;
  border-radius: 12px;
  padding: 12px 28px;
  margin-top: 15px;
  box-shadow: 4px 4px 0 #0003;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-ai-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 #0003;
}

.pie-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto;
}

.pie-chart {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid #1b1b1b;
  background: conic-gradient(
    #4CAF50 var(--easy),
    #E53935 var(--easy) calc(var(--easy) + var(--ai))
  );
  box-shadow: 4px 4px 0 #00000035;
  transition: background 0.8s ease;
}

/* Tekstid ringi sees */
.pie-label {
  position: absolute;
  width: 70px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1b1b1b;
  text-shadow: 1px 1px 2px #ffffff80;
}

/* Roheline tekst (asetame sektorisse vasakule alla) */
.pie-label-easy {
  top: 55%;
  left: 15%;
  transform: translate(-50%, -50%);
}

/* Punane tekst (asetame sektorisse paremale üles) */
.pie-label-ai {
  top: 35%;
  left: 75%;
  transform: translate(-50%, -50%);
}

.result-wrap {
  text-align: center;
  padding: 10px 6px;
}

.result-title {
  font-weight: 800;
  font-size: 1.6rem;
  margin-bottom: 20px;
  color: #1b1b1b;
}

.bar-label {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 6px 0 4px 0;
  color: #1b1b1b;
}

.bar-chart {
  width: 90%;
  max-width: 420px;
  height: 32px;
  margin: 0 auto 12px auto;
  background: #ffffff70;
  border-radius: 10px;
  border: 3px solid #1b1b1b;
  box-shadow: 3px 3px 0 #00000025;
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s ease;
}

.bar-easy {
  background: linear-gradient(180deg, #4CAF50, #3d8c3c);
}

.bar-ai {
  background: linear-gradient(180deg, #E53935, #c92d2a);
}


/* === PILDIFAILI / HIGHLIGHT FUNKTSIOONI STIILID === */

/* kogu highlight-blokk ühtses tulbas keskel */
#highlight-section {
  margin: 40px auto;
  max-width: 960px;
  position: relative;
  z-index: 1;
}

/* faili valimise input keskele + sama stiiliga nupp */
#image-input {
  display: block;
  margin: 30px auto 10px;
  font-size: 0.95rem;
  color: #e4f4ff;
}

/* nupp ise – sama loogika mis .btn */
#image-input::file-selector-button {
  font-family: inherit;
  font-size: 1.05rem;
  padding: 12px 22px;
  margin-right: 12px;
  border-radius: 12px;
  min-width: 160px;
  cursor: pointer;
  font-weight: 700;
  background: #fff;
  color: #111;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

#image-input:hover::file-selector-button {
  background: #f9f9f9;
  transform: translateY(-2px) scale(1.03);
}

#image-input:active::file-selector-button {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

/* === PILDIFAILI / HIGHLIGHT FUNKTSIOONI STIILID === */

/* kogu highlight-blokk ühtses tulbas keskel */
#highlight-section {
  margin: 40px auto;
  max-width: 960px;
  position: relative;
  z-index: 1;
  text-align: center;
}

/* sissejuhatav lause faili valiku ees */
#highlight-section .highlight-intro {
  margin-bottom: 10px;
  color: #e4f4ff;
  font-size: 1rem;
  opacity: 0.9;
}

/* faili valimise input keskele + sama stiiliga nupp */
#highlight-section #image-input {
  display: block;
  margin: 10px auto 10px;
  font-size: 0.95rem;
  color: #e4f4ff;
}

#highlight-section #image-input::file-selector-button {
  font-family: inherit;
  font-size: 1.05rem;
  padding: 12px 22px;
  margin-right: 12px;
  border-radius: 12px;
  min-width: 160px;
  cursor: pointer;
  font-weight: 700;
  background: #fff;
  color: #111;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

#highlight-section #image-input:hover::file-selector-button {
  background: #f9f9f9;
  transform: translateY(-2px) scale(1.03);
}

#highlight-section #image-input:active::file-selector-button {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

/* pildiala – enam ei ole valge kast, ainult kerge raam */
#highlight-section #canvas-wrapper {
  margin: 20px auto 0;
  padding: 0;
  border-radius: 24px;
  border: 2px solid rgba(0,0,0,0.4);
  background: transparent;
  box-shadow: none;
  max-width: min(900px, 90vw);
  overflow: hidden;
}

/* ainult see canvas */
#highlight-section #canvas-wrapper canvas {
  cursor: crosshair;
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none; /* et sõrm ei scrolliks lehte joonistamise ajal */
}

/* nupurea paigutus highlight-funktsiooni jaoks */
#highlight-section .highlight-controls {
  margin: 18px auto 0;
  max-width: min(900px, 90vw);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* highlighti-nupud samas stiilis mis .btn */
#highlight-section .highlight-controls button {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 12px;
  min-width: 150px;
  cursor: pointer;
  font-weight: 700;
  background: #fff;
  color: #111;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

#highlight-section .highlight-controls button:hover:not(:disabled) {
  background: #f9f9f9;
  transform: translateY(-2px) scale(1.02);
}

#highlight-section .highlight-controls button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

#highlight-section .highlight-controls button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

/* markeri paksuse tekst */
#highlight-section .highlight-controls label {
  color: #e4f4ff;
  font-size: 0.95rem;
}

/* oleku tekst */
#highlight-section #status {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #dfefff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  min-height: 1.2em;
}

/* highlightitud fraasid – ilma kastita, lihtsalt tekstirida */
#highlight-section #phrases-output {
  margin: 8px auto 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 0.95rem;
  white-space: pre-wrap;
  color: #ffffff;
  max-width: min(480px, 80vw);
  text-align: center;
  box-shadow: none;
}

/* ALGSEISUS: kõik pildifunktsiooni elemendid peale faili valiku on peidus */
#highlight-section #canvas-wrapper,
#highlight-section .highlight-controls,
#highlight-section #status,
#highlight-section #phrases-output {
  display: none;
}

/* väike responsiivsus */
@media (max-width: 768px) {
  #highlight-section #canvas-wrapper {
    border-radius: 18px;
  }

  #highlight-section .highlight-controls button {
    min-width: 130px;
    font-size: 0.95rem;
  }
}

/* kui body'l on .play-mode, peidame sisestusväljadel põhineva vaate,
   aga jätame .button-row konteineri alles – peidame sealt ainult kindlad nupud */

body.play-mode #kasutajaTekst,
body.play-mode #abimaterjal,
body.play-mode .ai-slider-wrap,
body.play-mode #sonadeValik,
body.play-mode #valmisBtn,
body.play-mode #looNupudBtn,
body.play-mode #looKoikNupudBtn,
body.play-mode #looAIValikBtn,
body.play-mode #abimaterjalValmisBtn,
body.play-mode #koikBtn,
body.play-mode #highlight-section {
  display: none !important;
}

/* jutumull jääb alles */

/* mängurežiimis taimer on nähtav;
   "Juhuslik sõna" nupu nähtavust juhib JS, mitte CSS ! */
body.play-mode #container.timer {
  display: flex !important;
}

/* Stardi valiku plokk – nihutame allapoole ja joondame ilusasti */
#start-choice {
  margin-top: 40px;        /* tõsta/ langeta vastavalt maitsele (nt 60px, kui tahad veel allapoole) */
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Et jutumull ja nupud oleksid tsentris */
#background {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#canvas-wrapper {
  position: relative;
  display: inline-block;
}

/* Undo nupp pildi peal, paremas ülanurgas */
#undo-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  cursor: pointer;

  /* väga kontrastne taust */
  background: rgba(0, 0, 0, 0.92);
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 20px;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);

  /* et mobiilis sõrmega lihtsam vajutada */
  touch-action: manipulation;
}

/* kui kasutad SVG-ikooni, siis see oleks kindlalt valge */
#undo-btn svg,
#undo-btn i {
  color: #fff;
  fill: #fff;
}


