* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  line-height: 1.6;
  background: #f0f0f0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

.container {
  background: #fafafa;
  max-width: 600px;
  width: 100%;
  margin: 2rem;
  padding: 2rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

h1 {
  text-align: center;
  margin-top: 0;
}

.display {
  text-align: center;
  font-size: clamp(3rem, 8vw, 8rem);
  margin: 1rem 0;
}

#result .group-number {
  font-size: 0.5em;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  flex: 1 1 120px;
}

.field input[type=number] {
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.switch-field {
  flex-direction: row;
  align-items: center;
  flex: 1 1 100%;
  gap: 0.5rem;
}

.switch-field input[type=checkbox] {
  appearance: none;
  width: 40px;
  height: 20px;
  background: #e2e8f0;
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 0.2s;
}

.switch-field input[type=checkbox]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch-field input[type=checkbox]:checked {
  background: #a5b4fc;
}

.switch-field input[type=checkbox]:checked::before {
  transform: translateX(20px);
}

.buttons {
  display: flex;
  gap: 1rem;
  flex: 1 1 100%;
}

button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 4px;
  background: #a5b4fc;
  color: #1e293b;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

button:hover {
  background: #9ba2fa;
}

button:active {
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transform: translateY(1px);
}

#generate {
  background: #bbf7d0;
}

#generate:hover {
  background: #a7e9bf;
}

#reset {
  background: #fecaca;
}

#reset:hover {
  background: #fda4a4;
}

#erase {
  background: #fef9c3;
  color: #1e293b;
}

#erase:hover {
  background: #fde68a;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus, input:focus {
  outline: 2px solid #4b5563;
  outline-offset: 2px;
}

.error {
  color: #d00;
  min-height: 1.2rem;
}

.status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.history {
  margin-top: 1.5rem;
}

.history h2 {
  font-size: 1.2rem;
}

#history {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#history li {
  background: #f9fafb;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
}

.history button {
  margin-top: 0.5rem;
}

.groups {
  margin-top: 1.5rem;
}

.groups h2 {
  font-size: 1.2rem;
}

.groups-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.groups-header .gsize-input {
  width: 3rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.groups-header .gsize-sep {
  font-weight: bold;
}

.groups-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.group {
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.5rem;
  min-width: 80px;
}

.group h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.group li {
  background: #f9fafb;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.3rem;
  text-align: center;
}


.copy-wrapper {
  position: relative;
  display: inline-block;
}

#copyHistory {
  background: transparent;
  padding: 0;
  color: #000;
}

#copyHistory:hover {
  background: transparent;
}

.copy-wrapper img {
  width: 16px;
  height: 16px;
}

.tooltip {
  position: absolute;
  top: -1.8rem;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.tooltip.show {
  opacity: 1;
}

.lang-buttons {
  margin-top: 1.5rem;
  text-align: center;
}

.lang-buttons button {
  margin: 0 0.5rem;
}

.lang-sep {
  color: #888;
}

.home-button {
  position: fixed;
  top: 10px;
  left: 10px;
  text-decoration: none;
  font-size: 24px;
  color: #000;
  opacity: 0.6;
  z-index: 1000;
}

.home-button:hover {
  opacity: 1;
}

.countdown {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  background: rgba(0,0,0,0.6);
  color: #fff;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
  z-index: 2000;
}

.countdown.show {
  opacity: 1;
}
