:root {
  --ink: #2d2a24;
  --sun: #ffd56b;
  --sky: #c7f1e9;
  --accent: #ff7f50;
  --accent-2: #2f9e97;
  --card: #fffdf6;
  --shadow: rgba(34, 34, 34, 0.18);
  --border: rgba(45, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Fredoka", "Comic Sans MS", "Chalkboard SE", "Marker Felt",
    cursive;
  color: var(--ink);
  background: radial-gradient(
      circle at 20% 20%,
      #fff4c8 0%,
      #ffecc1 35%,
      transparent 60%
    ),
    radial-gradient(circle at 80% 0%, #c7f1e9 0%, transparent 55%),
    linear-gradient(135deg, #fff8de 0%, #f8f1ff 60%, #e9fff8 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  opacity: 0.2;
  pointer-events: none;
}

body::before {
  background: #ffb289;
  top: -80px;
  right: -80px;
}

body::after {
  background: #7cd8d0;
  bottom: -120px;
  left: -120px;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: clamp(16px, 3vw, 32px);
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.title-block {
  max-width: 520px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b5d45;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.subtitle {
  margin: 0;
  font-size: 1.05rem;
  color: #564b39;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.05);
}

.controls label {
  font-size: 0.9rem;
  font-weight: 600;
}

select {
  appearance: none;
  border: 2px solid rgba(45, 42, 36, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--ink);
}

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-area {
  width: min(90vw, 560px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  position: relative;
}

.card-shell {
  position: relative;
  width: 100%;
}

.fullscreen-toggle {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fullscreen-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.16);
}

.fullscreen-toggle:active {
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
}

.fullscreen-toggle:focus-visible {
  outline: 3px solid rgba(47, 158, 151, 0.35);
  outline-offset: 2px;
}

.fullscreen-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen-icon.icon-exit {
  display: none;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.status,
.counter {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.status--hidden {
  display: none;
}

.status--hidden + .counter {
  margin-left: auto;
}

.status--notice {
  background: #ffe2b6;
  border-color: rgba(255, 127, 80, 0.4);
  animation: bounce 0.6s ease;
}

.error {
  padding: 12px 16px;
  border-radius: 12px;
  background: #ffebe2;
  border: 1px solid rgba(255, 127, 80, 0.4);
  font-size: 0.95rem;
}

.card {
  position: relative;
  width: 100%;
  min-height: clamp(240px, 50vh, 420px);
  border-radius: 28px;
  cursor: pointer;
  perspective: 1200px;
  box-shadow: 0 18px 32px var(--shadow);
  outline: none;
}

.card:focus-visible {
  box-shadow: 0 0 0 4px rgba(47, 158, 151, 0.35), 0 18px 32px var(--shadow);
}

.card-inner {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  transform-style: preserve-3d;
  transition: transform 0.55s ease;
  animation: floatIn 0.6s ease;
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: var(--card-font-size, clamp(2.6rem, 12vw, 5.8rem));
  font-weight: 600;
  letter-spacing: 0.02em;
  backface-visibility: hidden;
  border: 3px solid rgba(255, 255, 255, 0.6);
}

.card-front {
  background: linear-gradient(160deg, #ffffff 0%, #fff5d6 100%);
}

.card-back {
  background: linear-gradient(160deg, #e8fff8 0%, #d9f4ff 100%);
  transform: rotateY(180deg);
}

.card:not(.has-back) .card-back {
  display: none;
}

.hint {
  text-align: center;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed rgba(45, 42, 36, 0.2);
}

.footer {
  font-size: 0.85rem;
  color: #6a5c47;
  text-align: center;
}

body.fullscreen-active {
  overflow: hidden;
}

body.fullscreen-active .page {
  padding: 0;
  gap: 0;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
}

body.fullscreen-active .header,
body.fullscreen-active .footer {
  display: none;
}

body.fullscreen-active .main {
  width: 100%;
}

body.fullscreen-active .card-area {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  gap: 0;
  flex: 1;
  justify-content: stretch;
}

body.fullscreen-active .status-row,
body.fullscreen-active .hint {
  position: absolute;
  z-index: 2;
  left: 16px;
  right: 16px;
  pointer-events: none;
}

body.fullscreen-active .status-row {
  top: max(16px, env(safe-area-inset-top));
  right: max(72px, calc(16px + env(safe-area-inset-right)));
}

body.fullscreen-active .hint {
  bottom: max(16px, env(safe-area-inset-bottom));
}

body.fullscreen-active .card-shell {
  flex: 1;
  height: 100%;
}

body.fullscreen-active .card {
  height: 100%;
  min-height: 0;
  border-radius: 0;
  box-shadow: none;
}

body.fullscreen-active .card-inner,
body.fullscreen-active .card-face {
  border-radius: 0;
}

body.fullscreen-active .fullscreen-toggle .icon-enter {
  display: none;
}

body.fullscreen-active .fullscreen-toggle .icon-exit {
  display: block;
}

@keyframes floatIn {
  from {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes bounce {
  0% {
    transform: scale(0.95);
  }
  60% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 720px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    width: 100%;
  }

  select {
    width: 100%;
  }

  .card-area {
    width: 100%;
  }
}
