* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
}

body {
  font-family: Arial, sans-serif;
  color: #202020;
  background:
    radial-gradient(circle at top left, #fff4a3, transparent 35%),
    radial-gradient(circle at bottom right, #ffe0b2, transparent 35%),
    linear-gradient(135deg, #f7fbff, #fff8ed);
  overflow-x: hidden;
}

button {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(0.96);
}

.hidden {
  display: none !important;
}

.app {
  width: 100vw;
  min-height: 100dvh;
}

/* START */

.start-screen {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.start-card {
  width: min(900px, 94vw);
  min-height: min(580px, 86vh);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 36px;
}

.start-animal {
  font-size: clamp(80px, 12vw, 130px);
  line-height: 1;
}

.start-card h1 {
  font-size: clamp(40px, 6vw, 70px);
  margin: 8px 0;
  line-height: 1;
}

.start-card p {
  max-width: 760px;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.25;
  margin: 8px 0 32px;
}

#startBtn {
  font-size: clamp(26px, 3.5vw, 36px);
  padding: 20px 48px;
  border-radius: 999px;
  background: #ffcf33;
  box-shadow: 0 9px 0 #c99800;
}

/* SPIELSEITE */

.game-screen {
  width: 100%;
  min-height: 100dvh;
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 14px;
}

.game-header {
  min-height: 84px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.game-header h1 {
  font-size: clamp(34px, 4vw, 52px);
  margin: 0;
  line-height: 1;
}

.game-header p {
  font-size: clamp(18px, 2vw, 24px);
  margin: 6px 0 0;
  font-weight: 700;
  color: #555;
}

.stats {
  display: flex;
  gap: 14px;
}

.stat-box {
  min-width: 120px;
  border-radius: 22px;
  background: #fff4e2;
  padding: 10px 16px;
  text-align: center;
  box-shadow: inset 0 0 0 4px #ffd59a;
}

.stat-box span {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: #555;
}

.stat-box strong {
  display: block;
  font-size: 38px;
  line-height: 1;
}

/* HAUPTLAYOUT */

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  gap: 14px;
}

.left-panel,
.right-panel,
.table-section {
  min-height: 0;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  padding: 16px;
}

/* LINKS */

.left-panel {
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  gap: 12px;
}

.animal-card {
  min-height: 0;
  border-radius: 28px;
  background: #fff3bd;
  box-shadow: inset 0 0 0 5px #ffd84d;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 12px;
}

.animal {
  font-size: clamp(90px, 13vw, 190px);
  line-height: 1;
}

.animal-name {
  font-size: clamp(30px, 3.4vw, 44px);
  font-weight: 900;
  margin-top: 4px;
}

.task-card {
  border-radius: 28px;
  background: #fff4e2;
  box-shadow: inset 0 0 0 5px #ffbd66;
  padding: 12px;
  text-align: center;
}

.task-label {
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 900;
}

.multiplication-task {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
  margin: 8px 0;
  font-size: clamp(76px, 11vw, 150px);
  line-height: 1;
  font-weight: 900;
}

.operator {
  color: #fb8c00;
}

.pair-hint {
  display: inline-block;
  margin-top: 8px;
  border-radius: 999px;
  padding: 8px 14px;
  background: #ffffff;
  border: 3px solid #ffd59a;
  font-size: clamp(17px, 1.7vw, 22px);
  font-weight: 900;
  color: #34425c;
}

.feedback {
  min-height: 58px;
  border-radius: 22px;
  background: #f5f5f5;
  box-shadow: inset 0 0 0 4px #e3e3e3;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px 16px;
  font-size: clamp(20px, 2.2vw, 32px);
  font-weight: 900;
}

.feedback.good {
  color: #138a1d;
  background: #e3ffdf;
  box-shadow: inset 0 0 0 4px #87db7b;
}

.feedback.try {
  color: #bc7700;
  background: #fff1cc;
  box-shadow: inset 0 0 0 4px #ffc95c;
}

.restart-btn {
  justify-self: center;
  font-size: 21px;
  padding: 12px 28px;
  border-radius: 999px;
  background: #e9e9e9;
  box-shadow: 0 6px 0 #bdbdbd;
}

/* RECHTS */

.right-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.pad-title {
  text-align: center;
  font-size: clamp(32px, 3.8vw, 46px);
  font-weight: 900;
  line-height: 1;
}

.answer-pad {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
}

.answer-pad button {
  min-width: 0;
  min-height: 0;
  border-radius: 20px;
  background: #ffffff;
  border: 4px solid #eeeeee;
  box-shadow: 0 6px 0 #cccccc;
  font-size: clamp(30px, 4vw, 66px);
  color: #222;
  line-height: 1;
  padding: 8px;
}

.answer-pad button:hover {
  background: #fffaf1;
}

.answer-pad button.correct-flash {
  background: #a4ff91;
  border-color: #5ad64a;
  box-shadow: 0 6px 0 #3ca331;
}

.answer-pad button.wrong-flash {
  background: #ffd47c;
  border-color: #ffb02e;
  box-shadow: 0 6px 0 #c47d00;
}

.hint-box {
  border-radius: 20px;
  background: #fff4e2;
  box-shadow: inset 0 0 0 4px #ffd59a;
  padding: 12px;
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.2;
  text-align: center;
  font-weight: 800;
  color: #34425c;
}

/* TABELLE */

.table-section {
  display: grid;
  gap: 16px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.table-header h2 {
  margin: 0;
  font-size: clamp(30px, 3.5vw, 44px);
  line-height: 1;
}

.table-header p {
  margin: 6px 0 0;
  font-size: 18px;
  color: #555;
  font-weight: 800;
}

.table-toggle-btn {
  font-size: 18px;
  padding: 12px 22px;
  border-radius: 999px;
  background: #fff4e2;
  box-shadow: 0 5px 0 #d9a04d;
}

.multiplication-table-wrap {
  overflow-x: auto;
  border-radius: 22px;
  background: #ffffff;
  border: 4px solid #ffd59a;
}

.multiplication-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.multiplication-table th,
.multiplication-table td {
  border: 2px solid #f0e0ca;
  text-align: center;
  padding: 12px 8px;
  font-size: 22px;
  font-weight: 900;
}

.multiplication-table thead th,
.multiplication-table tbody th {
  background: #fff4e2;
  color: #4d3420;
}

.multiplication-table td {
  background: #ffffff;
}

.multiplication-table td.active-cell {
  background: #ffcf33;
  outline: 4px solid #fb8c00;
  outline-offset: -4px;
}

/* ANIMATION */

.animal-success {
  animation: animalBounce 0.5s ease;
}

@keyframes animalBounce {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.18) rotate(-4deg);
  }

  70% {
    transform: scale(0.95) rotate(4deg);
  }

  100% {
    transform: scale(1);
  }
}

/* KOMPAKT FÜR 1024 x 768 / 1024 x 786 */

@media (max-width: 1100px), (max-height: 820px) {
  .game-screen {
    padding: 10px;
    gap: 10px;
  }

  .game-header {
    min-height: 64px;
    padding: 8px 18px;
    border-radius: 22px;
  }

  .game-header h1 {
    font-size: 32px;
  }

  .game-header p {
    font-size: 17px;
    margin-top: 2px;
  }

  .stats {
    gap: 10px;
  }

  .stat-box {
    min-width: 92px;
    padding: 7px 12px;
    border-radius: 18px;
    box-shadow: inset 0 0 0 3px #ffd59a;
  }

  .stat-box span {
    font-size: 15px;
  }

  .stat-box strong {
    font-size: 31px;
  }

  .game-layout {
    grid-template-columns: 0.95fr 1.05fr;
    gap: 10px;
  }

  .left-panel,
  .right-panel,
  .table-section {
    padding: 10px;
    border-radius: 24px;
  }

  .left-panel {
    gap: 8px;
    grid-template-rows: 0.9fr auto auto auto;
  }

  .right-panel {
    gap: 8px;
  }

  .animal-card {
    border-radius: 22px;
    padding: 8px;
    box-shadow: inset 0 0 0 4px #ffd84d;
  }

  .animal {
    font-size: clamp(72px, 11vw, 130px);
  }

  .animal-name {
    font-size: 28px;
    margin-top: 0;
  }

  .task-card {
    border-radius: 22px;
    padding: 8px;
    box-shadow: inset 0 0 0 4px #ffbd66;
  }

  .task-label {
    font-size: 21px;
  }

  .multiplication-task {
    font-size: clamp(58px, 8.8vw, 105px);
    gap: 12px;
  }

  .pair-hint {
    font-size: 16px;
    padding: 6px 11px;
    margin-top: 5px;
    border-width: 2px;
  }

  .feedback {
    min-height: 44px;
    border-radius: 18px;
    font-size: 20px;
    padding: 5px 12px;
  }

  .restart-btn {
    font-size: 18px;
    padding: 8px 22px;
    box-shadow: 0 4px 0 #bdbdbd;
  }

  .pad-title {
    font-size: 30px;
  }

  .answer-pad {
    gap: 7px;
  }

  .answer-pad button {
    border-radius: 15px;
    border-width: 3px;
    box-shadow: 0 4px 0 #cccccc;
    font-size: clamp(24px, 3.2vw, 46px);
    padding: 5px;
  }

  .hint-box {
    font-size: 16px;
    padding: 8px;
    border-radius: 16px;
    box-shadow: inset 0 0 0 3px #ffd59a;
  }

  .table-header h2 {
    font-size: 30px;
  }

  .table-header p {
    font-size: 16px;
  }

  .multiplication-table th,
  .multiplication-table td {
    font-size: 18px;
    padding: 9px 6px;
  }
}

/* SEHR NIEDRIGE HÖHE */

@media (max-height: 700px) {
  .game-header {
    min-height: 54px;
  }

  .game-header h1 {
    font-size: 26px;
  }

  .game-header p {
    font-size: 15px;
  }

  .stat-box {
    min-width: 82px;
    padding: 5px 10px;
  }

  .stat-box span {
    font-size: 13px;
  }

  .stat-box strong {
    font-size: 26px;
  }

  .animal {
    font-size: clamp(58px, 9vw, 105px);
  }

  .animal-name {
    font-size: 24px;
  }

  .task-label {
    font-size: 18px;
  }

  .multiplication-task {
    font-size: clamp(48px, 7.5vw, 86px);
  }

  .pair-hint {
    font-size: 14px;
    padding: 5px 9px;
  }

  .feedback {
    min-height: 38px;
    font-size: 17px;
  }

  .restart-btn {
    font-size: 16px;
    padding: 7px 18px;
  }

  .pad-title {
    font-size: 25px;
  }

  .answer-pad {
    gap: 6px;
  }

  .answer-pad button {
    font-size: clamp(22px, 2.8vw, 38px);
    border-radius: 12px;
    box-shadow: 0 3px 0 #cccccc;
  }

  .hint-box {
    font-size: 14px;
    padding: 6px;
  }
}

/* TABLET / KLEINER */

@media (max-width: 850px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100dvh;
  }

  .game-screen {
    height: auto;
    min-height: 100dvh;
  }

  .game-header {
    flex-direction: column;
    text-align: center;
  }

  .stats {
    width: 100%;
    justify-content: center;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .right-panel {
    min-height: auto;
  }

  .animal-card {
    min-height: 180px;
  }

  .answer-pad {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto;
  }

  .answer-pad button {
    min-height: 78px;
  }
}

@media (max-width: 520px) {
  .game-screen {
    padding: 8px;
  }

  .game-header h1 {
    font-size: 30px;
  }

  .game-header p {
    font-size: 16px;
  }

  .stat-box {
    min-width: 105px;
  }

  .animal-card {
    min-height: 150px;
  }

  .animal {
    font-size: 90px;
  }

  .animal-name {
    font-size: 26px;
  }

  .multiplication-task {
    font-size: 70px;
  }

  .answer-pad {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .answer-pad button {
    min-height: 68px;
    font-size: 30px;
    border-radius: 15px;
  }

  .multiplication-table {
    min-width: 680px;
  }
}