html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  direction: rtl;
  user-select: none;
  overflow: hidden;
}

body {
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
}

/* — Button style — */
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #0008;
  border-radius: 4px;
  padding: 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, transform 0.1s;
}

.button:hover {
  background: #f0f0f0;
}

.button:active {
  background: #ddd;
  transform: scale(0.98);
}

/* — Level & operation selection overlay — */
#main-title {
  font-size: 2em;
  font-weight: bold;
  color: white;
  background: linear-gradient(0deg, #fff8 0%, #fff4 10%, #fff0 50%, #fff4 90%, #fff8 100%);
  padding: 15px;
  margin-bottom: 30px;
  border-radius: 5px;
  border: 2px solid #fff8;
  text-align: center;
}

#level-selection {
  position: absolute;
  top: 0;
  left: 0;
  width: 100dvw;
  height: 100dvh;
  max-height: 100dvh;
  background: cornflowerblue;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  box-sizing: border-box;
  direction: ltr;
  z-index: 10;
  justify-content: center;
}

/* Operation buttons row */
#op-selection {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
}

.op-button {
  width: 50px;
  height: 50px;
  font-size: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, transform 0.1s;
}

.op-button:hover {
  background: #f0f0f0;
}

.op-button:active {
  background: #ddd;
  transform: scale(0.98);
}

.op-button.selected {
  background: mediumslateblue;
  color: #fff;
}

/* Level cards grid */
.level-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 28dvw);
  grid-auto-rows: 15dvh;
  gap: 15px;
  justify-content: center;
  align-content: center;
}

.level-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
}

.level-card .high-score {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: mediumslateblue;
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  display: none;
  width: 32px;
  text-align: center;
}

.level-card[data-level="11"] {
  grid-column: span 2;
}

.level-card .medal {
  position: absolute;
  top: 0;
  right: 0;
}

.button.level-card {
  padding-bottom: 36px;
  border: none;
}

#game-container {
  position: relative;
  flex: 1;
  background: cornflowerblue;
  overflow: hidden;
}

#hearts {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 24px;
}

#score-container {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 24px;
  color: white;
  font-weight: bold;
}

#bubble-container {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  font-size: 24pt;
  background: #fff;
  padding: 20px;
  border: 8px solid mediumslateblue;
  border-radius: 10px;
  text-align: center;
  line-height: 1.67;
  z-index: 5;
  width: 225px;
}

.bubble {
  position: absolute;
  left: 0;
  top: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(#add2f7ee 30%, #fffa 100%);
  box-shadow: 0px 0px 5px #fff8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  will-change: transform;
  direction: ltr;
}

.bubble.golden {
  background: radial-gradient(#ffd700ee 30%, #fffa 100%);
  ;
}

#keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 5px;
  padding: 10px;
  background: #eee8;
  direction: ltr;
  position: absolute;
  left: 0;
  bottom: 0;
  width: calc(100% - 20px);
}

#answer-display {
  grid-column: span 3;
  height: 50px;
  font-size: 32px;
  text-align: right;
  background: #fffd;
  padding: 0 10px;
  line-height: 50px;
  border: 1px solid #0008;
  border-radius: 4px;
  text-align: center;
}

#keypad .button {
  background: #fffd;
  font-size: clamp(16px, 5vw, 24px);
}