*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f0f0;
  position: relative;
}

body.secret-view {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 35%, #0f3460 70%, #1a1a2e 100%);
  background-attachment: fixed;
}

body.secret-view::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(34, 197, 94, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.02) 2px, rgba(255,255,255,0.02) 4px);
  pointer-events: none;
  z-index: 0;
}

body.settings-view {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 35%, #0f3460 70%, #1a1a2e 100%);
  background-attachment: fixed;
}

body.settings-view::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(249, 115, 22, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.02) 2px, rgba(255,255,255,0.02) 4px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  content: none;
}

body.page-leaving {
  opacity: 0;
  transition: opacity 0.22s ease;
}

body.page-enter {
  animation: pageEnter 0.35s ease forwards;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.green-buttons.revealed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  justify-content: center;
  align-items: stretch;
  justify-items: stretch;
  padding-top: 16px;
  animation: revealIn 0.4s ease forwards;
}

@keyframes revealIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.page-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.page-ornament {
  display: none;
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.02em;
}

body.secret-view .page-ornament {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #22c55e, #4ade80, #22c55e, transparent);
  opacity: 0.9;
}

body.secret-view .page-title {
  color: #e2e8f0;
  text-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.calculator {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 16px;
  width: 280px;
}

.display {
  width: 100%;
  height: 56px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 28px;
  text-align: right;
  padding: 0 12px;
  margin-bottom: 12px;
  background: #fafafa;
  color: #333;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.btn {
  height: 52px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 500;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover {
  background: #ebebeb;
}

.btn:active {
  background: #e0e0e0;
}

.btn-operator {
  background: #e8e8e8;
  font-size: 22px;
}

.btn-operator:hover {
  background: #ddd;
}

.btn-clear {
  background: #ffebee;
  color: #c62828;
}

.btn-clear:hover {
  background: #ffcdd2;
}

.btn-equals {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.btn-equals:hover {
  background: #1565c0;
}

.btn-zero {
  grid-column: span 2;
}

.green-buttons {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 800px;
  padding: 24px;
}

.back-to-calc-btn {
  grid-column: 1 / -1;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  margin-bottom: 8px;
  font-family: inherit;
}

.back-to-calc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.green-btn {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 2.5vw, 28px);
  font-weight: 500;
  color: #fff;
  background: #22c55e;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35), 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease;
  text-decoration: none;
}

.green-btn-link {
  text-align: center;
}

.green-btn:hover {
  background: #16a34a;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4), 0 2px 4px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.green-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(34, 197, 94, 0.3);
}

.rumble-mini {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.rumble-mini[hidden] {
  display: none;
}

.rumble-mini-inner {
  background: #fff;
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.rumble-mini-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.rumble-mini-header h2 {
  margin: 0;
  font-size: 22px;
  color: #333;
}

.rumble-close {
  width: 36px;
  height: 36px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #666;
}

.rumble-close:hover {
  background: #e0e0e0;
  color: #333;
}

.rumble-hint {
  color: #666;
  font-size: 14px;
  margin: 0 0 12px 0;
}

.rumble-form {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.rumble-input {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

.rumble-watch-btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: #22c55e;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.rumble-watch-btn:hover {
  background: #16a34a;
}

.rumble-error {
  color: #c62828;
  font-size: 14px;
  margin: 0 0 12px 0;
}

.rumble-video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #111;
  margin-top: 12px;
}

.rumble-video-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.settings-corner-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border: none;
  border-radius: 9999px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.settings-corner-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.5);
}
