/* ========================================= */
/* 🎨 VARIABLES                              */
/* ========================================= */
:root {
  --main-font: 'Trebuchet MS', sans-serif;
  --main-font-style: italic;
}


/* ========================================= */
/* 🎨 BASE & TYPOGRAPHY                      */
/* ========================================= */

/* Reset & background */
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* Zapobiega scrollowi całej strony */
  font-family: var(--main-font);
  font-style: var(--main-font-style);
  background: linear-gradient(120deg, #fceabb 0%, #f8b500 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: #333;
}

/* Section headings */
h2 {
  font-size: 1.8em;
  font-weight: 700;
  color: #2b3c59;
  text-shadow: 1px 1px 0 #fff;
}

/* Question text */
#question {
  font-size: 2.8em;
  margin-bottom: 25px;
  color: #ff5722;
  text-shadow: 1px 1px 1px #ffccbc;
}


/* ========================================= */
/* 📐 LAYOUT & CONTAINERS                    */
/* ========================================= */

/* Wrapper fills viewport */
.game-wrapper {
  box-sizing: border-box;
  padding: 80px 20px 20px;
  height: 100vh; /* Zapełnia cały widoczny ekran */
  overflow-y: auto; /* Pozwala na przewijanie, jeśli treści jest dużo */
  position: relative; /* pozwala używać overlay i sticky */
}

/* Centered game panel */
.game-container {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #fff8e1;
  border: 4px dashed #ffb347;
  border-radius: 18px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.15);
  transition: box-shadow 0.3s;
}
.game-container:hover {
  box-shadow: 0 0 0 4px #ffdca8;
}

/* Sticky scoreboard */
.scoreboard {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 24px;
  padding: 12px 0;
  margin: 0;
  width: 100%;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  z-index: 1050;
}
.score-wrapper {
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.score-value {
  font-size: 1.6em;
  font-weight: bold;
  min-width: 60px;
  padding: 10px 16px;
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 12px;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
  color: #2c3e50;
  text-align: center;
}
.score-label {
  margin-top: 6px;
  font-size: 1em;
  font-weight: 500;
  color: #5d6d7e;
}


/* ========================================= */
/* 🖋 FORM ELEMENTS                          */
/* ========================================= */

/* Answer input */
#game-answer-field {
  font-size: 2.4em;
  text-align: center;
  padding: 14px;
  width: 120px;
  border: 3px solid #ff9800;
  border-radius: 16px;
  background: #fffdf8;
  color: #333;
  box-shadow: inset 0 2px 4px rgba(255,152,0,0.2);
  transition: 0.2s ease;
}
#game-answer-field::placeholder {
  color: #999;
  font-size: 0.85em;
}
/* Remove spinners */
#game-answer-field::-webkit-outer-spin-button,
#game-answer-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#game-answer-field[type=number] {
  -moz-appearance: textfield;
}
/* Focus state */
#game-answer-field:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 6px rgba(0,122,204,0.6);
  background-color: #fff;
}

/* Check button */
.check-button {
  font-size: 1.5em;
  padding: 12px 24px;
  margin-top: 20px;
  font-weight: bold;
  background: linear-gradient(to bottom right, #81c784, #66bb6a);
  color: white;
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 0 #4caf50;
  transition: transform 0.1s ease;
}
.check-button:hover {
  background: linear-gradient(to bottom right, #a5d6a7, #81c784);
}
.check-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0194a3;
}


/* ========================================= */
/* 🔘 NAVIGATION & MENUS                     */
/* ========================================= */

/* Side buttons */
.side-buttons {
  position: absolute;
  top: 16px;
  left: -70px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}
.side-buttons button {
  width: 58px;
  height: 58px;
  font-size: 2em;
  font-weight: bold;
  background: linear-gradient(to bottom right, #ffffff, #f0f0f8);
  color: #3a0088;
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(58,0,136,0.2);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}
.side-buttons button:hover {
  background: linear-gradient(to bottom right, #dfe7ff, #c9d2ff);
  box-shadow: 0 3px 6px rgba(58,0,136,0.35);
  transform: scale(1.05);
}
.side-buttons button:active {
  background: linear-gradient(to bottom right, #c5cfff, #b3bfff);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  transform: scale(0.95);
}

/* Settings panel */
.settings-panel {
  position: fixed;
  top: 0;
  right: -240px;
  max-width: 220px;
  width: auto;
  height: 100%;
  background: linear-gradient(to bottom, #fff8e1, #fff3c0);
  border-left: 3px solid #f4c542;
  box-shadow: -4px 0 10px rgba(0,0,0,0.2);
  padding: 100px 10px 10px;
  overflow-y: auto;
  transition: right 0.4s ease;
  z-index: 1001;
}
.settings-panel.visible {
  right: 0;
}
.panel-header {
  font-size: 1.4em;
  font-weight: bold;
  margin-bottom: 12px;
  color: #d35400;
}
.section-title {
  font-size: 1.3em;
  font-weight: bold;
  margin: 0 0 10px 0;
  color: #d35400;
}


/* ========================================= */
/* ⬇️ EXPANDABLE SECTIONS                     */
/* ========================================= */

.settings-section {
  margin-bottom: 20px;
}
.toggle-tabs {
  width: 100%;
  padding: 10px;
  font-size: 1.1em;
  background: #fff3c0;
  border: 2px solid #f4c542;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 8px;
}
#tabOptions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
#tabOptions.expanded {
  max-height: 500px;
}
.mode-button {
  text-align: left;
  padding: 10px;
  font-size: 1em;
  background: #fffef5;
  border: 2px solid #f4c542;
  border-radius: 10px;
  color: #333;
  cursor: pointer;
  transition: background 0.2s ease;
}
.mode-button.selected {
  background: #ffe082;
  color: #3a0088;
  font-weight: bold;
}


/* ========================================= */
/* 🔊 SOUND CONTROLS                          */
/* ========================================= */
.sound-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #fffef4;
  border: 2px solid #f4c542;
  border-radius: 12px;
  font-size: 1.1em;
  color: #333;
  cursor: default;
}
.sound-button {
  background: none;
  border: none;
  font-size: 1.6em;
  padding: 6px 12px;
  cursor: pointer;
  transition: transform 0.2s;
}
.sound-button:hover {
  transform: scale(1.2);
}


/* ========================================= */
/* 💬 FEEDBACK & MESSAGES                     */
/* ========================================= */

/* Static feedback */
.feedback {
  margin-top: 20px;
  font-size: 1.2em;
  font-weight: bold;
  min-height: 2em;
  text-align: center;
  color: #444;
  transition: color 0.2s ease;
}
.feedback.correct   { color: #028a0f; }
.feedback.incorrect { color: #c40000; }

/* Input states */
.correct-input   { color: green  !important; }
.incorrect-input { color: red    !important; }

/* Floating message */
.floating-message {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  font-size: 2.4em;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  z-index: 1200;
  text-align: center;
  animation: none;
}
.floating-message.correct   { color: #00b894; }
.floating-message.incorrect { color: #d63031; }

.correct-result {
  display: block;
  margin-top: 6px;
  font-size: 2em;
  font-weight: bold;
  color: #ff0000;
}


/* ========================================= */
/* 🖥 VIRTUAL NUMPAD                          */
/* ========================================= */
.numpad {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 60px);
  gap: 10px;
  justify-content: center;
  padding: 10px;
  background: #f7f7f7;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.numpad.hidden { display: none; }
.numpad .key {
  font-size: 1.4em;
  padding: 14px 0;
  background: #fff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: background 0.2s;
}
.numpad .key:hover { background: #e0e0e0; }
.numpad .zero,
.numpad .backspace { grid-column: span 3; }
.numpad .backspace {
  background-color: #e0e0e0;
  color: #333;
  font-weight: bold;
}
.numpad .backspace:hover { background-color: #cfcfcf; }


/* ========================================= */
/* ⏱ TIMER CONTROLS                           */
/* ========================================= */
.timer-section {
  padding: 16px;
  border: 2px solid #f4c542;
  border-radius: 12px;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.05);
}
.timer-inputs label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 1em;
}
.countdown {
  margin-top: 16px;
  font-size: 2.4em;
  text-align: center;
  font-weight: bold;
  color: #c0392b;
}
.timer-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  justify-content: center;
}
.timer-buttons button {
  flex: 1;
  padding: 10px;
  font-size: 1.1em;
  font-weight: bold;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}
/* Timer inputs */
.timer-inputs input[type="number"] {
  padding: 6px 10px;
  font-size: 1.2em;
  border: 2px solid #ccc;
  border-radius: 8px;
  width: 80px;
  text-align: center;
  background: #fffdf0;
}
#mobileTime {
  padding: 8px 12px;
  font-size: 1.2em;
  border: 2px solid #ccc;
  border-radius: 10px;
  width: 160px;
  text-align: center;
  background: #fffdf0;
  color: #2c3e50;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
}
/* Start/Stop buttons */
#startTimer {
  background-color: #00bcd4;
}
#startTimer:hover {
  background-color: #0097a7;
}
#startTimer:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0194a3;
}
#stopTimer {
  background-color: #e74c3c;
}
#stopTimer:hover {
  background-color: #c0392b;
}


/* ========================================= */
/* 🗄 SUMMARY OVERLAY                         */
/* ========================================= */
.hidden {
  display: none !important;
}
.summary-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
}
.summary-overlay.visible {
  display: flex;
}
.summary-box {
  position: relative;
  max-width: 320px;
  width: 90%;
  padding: 24px 32px;
  background: #fff;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.summary-box h2 {
  margin-top: 0;
}
.congrats {
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 12px;
  color: #27ae60;
}
.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  background: #eee;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9em;
}
.close-btn:hover {
  background-color: #ddd;
}


/* ========================================= */
/* 🔳 OVERLAY & MODAL                        */
/* ========================================= */
#infoButton {
  position: fixed;
  bottom: 1em;
  left: 1em;
  font-size: 2em;
  background: none;
  border: none;
  color: #7c5cff;
  cursor: pointer;
  z-index: 1500;
  transition: color 0.3s ease;
}
#infoButton:hover {
  color: #5c47c6;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: rgba(0,0,0,0.7);
  overflow-y: auto;
  z-index: 9999;
}
.overlay-content {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  padding: 2rem;
  background: #fff;
  color: #333;
  border-radius: 12px;
  box-sizing: border-box;
  overflow-y: auto;
  font-size: 1.1rem;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
}


/* ========================================= */
/* 🎞️ ANIMATIONS & TRANSITIONS               */
/* ========================================= */

/* Keyframes */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
@keyframes scorePop {
  0%   { transform: scale(1); background-color: #fff; }
  30%  { transform: scale(1.25); background-color: #d4edda; }
  100% { transform: scale(1); background-color: #fff; }
}
@keyframes scoreFlash {
  0%,100% { background-color: #fff; }
  50%     { background-color: #ffe0e0; }
}
@keyframes scaleUp {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes floatUpFade {
  0%   { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -100px); }
}

/* Animation helper classes */
.feedback-animate { animation: scaleUp    300ms ease-in-out; }
.animate-pop      { animation: scorePop   0.4s  ease; }
.animate-flash    { animation: scoreFlash  0.6s  ease; }
.fade, .fade-out  { transition: opacity   0.3s  ease; }

/* Global transitions */
.side-buttons button,
.sound-button,
.check-button,
.toggle-tabs,
.mode-button,
#infoButton {
  transition: background 0.2s ease,
              transform 0.1s ease,
              color 0.3s ease;
}


/* ========================================= */
/* 📱 RESPONSIVE (max-width: 480px)          */
/* ========================================= */
@media (max-width: 480px) {
  body  { font-size: 15px; }
  h2    { font-size: 1.2em; }
  #question { font-size: 1.6em; margin-bottom: 12px; }

  .game-container {
    padding-left: 50px;
    padding-right: 8px;
  }

  #game-answer-field {
    font-size: 1.6em;
    padding: 10px;
    width: 80px;
    margin-bottom: 0;
  }
  .check-button {
    font-size: 1.2em;
    padding: 10px 20px;
  }

  .side-buttons {
    left: 10px;
    font-size: 0.75em;
  }
  .side-buttons button {
    width: 44px;
    height: 44px;
  }

  .score-wrapper { flex-wrap: nowrap; }
  .score-value   { font-size: 1em; min-width: 20px; }
  .score-label   { font-size: 0.8em; }

  .overlay-content {
    padding: 1rem;
    font-size: 1rem;
  }
  .overlay-content h2 { font-size: 1.2em; }
  .overlay-content h3 { font-size: 1.1em; }
}
