/*
Theme Name: Captcha Game Theme
Theme URI: https://example.com/
Author: Your Name
Author URI: https://example.com/
Description: A theme wrapper for the Captcha Game project with a custom page template.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: captcha-game-theme
*/

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0,0,0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
}

#captcha-root {
  width: min(560px, calc(100vw - 32px));
  background: #ffffff;
  border: none;
}

.captcha-card {
  width: 100%;
  background: #ffffff;
  overflow: hidden;
}

.captcha-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px 16px;
  background: linear-gradient(90deg, #f8fafc 0%, #eef2ff 100%);
}

.captcha-verify-button {
  margin-left: auto;
  border: none;
  background: #4a90e2;
  color: white;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.captcha-verify-button:hover {
  transform: scale(1.1);
}

.captcha-verify-button:active {
  transform: scale(0.95);
  box-shadow: inset 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.captcha-logo {
  width: 12%;
  min-width: 40px;
  aspect-ratio: 1 / 1;
}

.captcha-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.captcha-brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.captcha-brand-subtitle {
  margin-top: 2px;
  font-size: 0.85rem;
  color: #4b5563;
}

.captcha-header {
  padding: 20px 24px;
  background: #4a90e2;
}

.captcha-instruction {
  font-size: 2.5rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}

.captcha-note {
  font-size: 1.5rem;
  color: #ffffff;
}

.captcha-frame {
  background: #ffffff;
  padding: 20px 24px 24px;
}

.captcha-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
}

.captcha-progress-label {
  font-size: 100%;
  font-weight: 600;
  color: #374151;
}

.captcha-steps {
  display: flex;
  gap: 3%;
  flex: 1;
  justify-content: flex-end;
}

.cg-progress-dot {
  width: 28px;
  height: 6px;
  border-radius: 999px;
  background: #d1d5db;
}
.cg-progress-dot.cg-progress-active { background: #3b82f6; }
.cg-progress-dot.cg-progress-done { background: #22c55e; }

.cg-module {
  border-radius: 18px;
  background: #ffffff;
  min-height: 330px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: none;
  box-shadow: none;
}

.cg-prompt {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: #111827;
}

.cg-verify-btn {
  margin-top: auto;
  align-self: flex-end;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background 0.2s ease;
  touch-action: manipulation;
  outline: none;
}
.cg-verify-btn:hover { background: #1d4ed8; }
.cg-verify-btn:active { background: #1e40af; }

.captcha-verify-button,
.captcha-link,
.cg-tile {
  outline: none;
}

.captcha-verify-button:focus,
.captcha-link:focus,
.cg-verify-btn:focus,
.cg-tile:focus {
  outline: none;
}

.cg-grid {
  display: grid;
  gap: 4px;
}

.cg-grid[data-rows="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cg-grid[data-rows="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cg-message {
  padding: 16px;
  border-radius: 16px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.95rem;
  line-height: 1.4;
}

.cg-tile {
  aspect-ratio: 1;
  background: #ffffff;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
  position: relative;
  /* reset default button spacing so images can fill the tile exactly */
  padding: 0;
  font-size: 0;
  min-width: 0;
  min-height: 0;
  /* default stroke variables used by border-mode */
  --sel-stroke: 0px;
  --sel-color: rgba(34,197,94,0.95);
}

.cg-tile-selected {
  border: none;
  background: rgba(34, 197, 94, 0.15);
}

.cg-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  transition: transform 360ms cubic-bezier(.2,.9,.2,1), filter 120ms ease;
  transform-origin: center center;
  will-change: transform;
  max-width: none;
  max-height: none;
}

/* Selection overlay sits above the image */
.cg-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;
  --sel-stroke: 0px; /* animatable inner stroke thickness */
  --sel-color: #ffffff;
  background: transparent;
  box-shadow: inset 0 0 0 var(--sel-stroke) var(--sel-color);
  transition: box-shadow 220ms cubic-bezier(.2,.9,.2,1), background 180ms ease;
}

.cg-tile-selected::after {
  --sel-stroke: 0.5rem; /* new stroke size (change this value to adjust thickness) */
}

/* slightly dim the image when selected so overlay is clearer */
.cg-tile-selected img {
  z-index: 1;
  transform: scale(1.15);
}

.cg-rotate-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  background: #eef2ff;
  border-radius: 16px;
}
.cg-rotate-icon {
  font-size: 4.5rem;
}
.cg-rotate-slider {
  width: 100%;
}

.cg-slider-track,
.cg-drag-board,
.cg-sequence-stage {
  border-radius: 16px;
  background: #eef2ff;
}

.cg-drag-board {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  min-height: 180px;
  user-select: none;
  -webkit-user-select: none;
}
.cg-drag-source {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: white;
  cursor: grab;
  touch-action: none;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cg-drag-zone {
  height: 56px;
  border: 2px dashed rgba(31, 41, 55, 0.15);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #6b7280;
}

.cg-sequence-stage {
  position: relative;
  height: 220px;
  background: #f8fafc;
  border-radius: 16px;
}
.cg-sequence-dot {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: white;
  font-weight: 700;
  transform: translate(-50%, -50%);
  cursor: pointer;
  touch-action: manipulation;
}
.cg-sequence-dot.cg-sequence-done {
  background: #22c55e;
}
.cg-sequence-dot.cg-sequence-failed {
  background: #ef4444;
}

.captcha-actions {
  display: flex;
  gap: 12px;
  padding: 16px 24px 24px;
  justify-content: flex-end;
}

.cg-success {
  text-align: center;
  padding: 36px 20px;
  font-size: 1.1rem;
}

.cg-leaderboard {
  margin-top: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 0;
  background: #f8fafc;
  padding: 16px;
}

.cg-leaderboard-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.cg-leaderboard-list {
  display: grid;
  gap: 8px;
}

.cg-leaderboard-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.cg-leaderboard-current {
  border-color: #2563eb;
  background: #eff6ff;
}

.cg-leaderboard-rank,
.cg-leaderboard-name,
.cg-leaderboard-time {
  font-size: 0.95rem;
}

.cg-name-form-wrapper {
  display: grid;
  gap: 10px;
  margin: 18px auto;
  max-width: 360px;
  width: 100%;
  padding: 16px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.cg-name-form-label {
  font-weight: 700;
  font-size: 0.95rem;
}

.cg-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 0;
  font-size: 0.95rem;
}

.cg-name-message {
  color: #111827;
  font-size: 0.9rem;
}

.cg-leaderboard-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

.cg-retry-button {
  align-self: center;
  padding: 14px 20px;
  font-size: 1rem;
}

.cg-success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.cg-time {
  margin-top: 12px;
  font-size: 0.95rem;
  color: #6b7280;
}
.cg-best {
  margin-top: 10px;
  font-size: 0.92rem;
  color: #16a34a;
}

@keyframes cg-shake-kf {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.cg-shake, .captcha-shake {
  animation: cg-shake-kf 0.4s;
}
