:root {
  --bg: #ffffff;
  --panel: #fffdf7;
  --panel-warm: #f4eddf;
  --ink: #111111;
  --shadow: #111111;
  --green: #86b84a;
  --brown: #9a5e38;
  --blue: #1684ff;
  --muted: #5f513f;
}

* {
  box-sizing: border-box;
}

html,
body,
button,
input,
select,
textarea {
  font-family: "Patrick Hand", "Comic Sans MS", "Comic Neue", "Trebuchet MS", cursive, sans-serif;
}

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  position: relative;
  color: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("background.png");
  background-repeat: repeat;
  background-size: 600px auto;
  background-position: center top;
}

a {
  color: var(--blue);
  text-decoration: none;
}

button,
a.big-button,
a.guest-button,
a.small-button,
a.new-game-button,
a.start-button {
  -webkit-tap-highlight-color: transparent;
}

/* Shared buttons */
.big-button,
.guest-button,
.new-game-button,
.join-game-button,
.start-button,
.small-button,
.small-action,
.login-button,
#giveUpBtn,
#doneBtn,
#scoreContinueBtn,
.toolbar button,
.avatar-choice {
  display: inline-block;
  border: 4px solid var(--ink);
  border-radius: 18px 22px 16px 20px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
  box-shadow: 5px 6px 0 var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.big-button:hover,
.guest-button:hover,
.new-game-button:hover,
.join-game-button:hover,
.start-button:hover,
.small-button:hover,
.small-action:hover,
.login-button:hover,
#giveUpBtn:hover,
#doneBtn:hover,
#scoreContinueBtn:hover,
.toolbar button:hover,
.avatar-choice:hover {
  transform: translateY(-2px);
  box-shadow: 7px 8px 0 var(--shadow);
}

.big-button:active,
.guest-button:active,
.new-game-button:active,
.join-game-button:active,
.start-button:active,
.small-button:active,
.small-action:active,
.login-button:active,
#giveUpBtn:active,
#doneBtn:active,
#scoreContinueBtn:active,
.toolbar button:active,
.avatar-choice:active {
  transform: translateY(4px);
  box-shadow: 2px 3px 0 var(--shadow);
}

#scoreContinueBtn {
    padding: 10px 20px;
}

/* Landing / center pages */
.center-page,
.home-page,
.landing-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: transparent;
}

.home-card,
.login-card,
.compact-card {
  width: min(760px, 92vw);
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.home-card {
  padding: 0;
}

.logo {
  width: min(485px, 78vw);
  margin: 0 auto -100px;
  padding-top: 60px;
  display: block;
  background: transparent;
  filter: drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.15));
}

.tagline {
  margin: 0 auto 55px;
  font-size: clamp(22px, 3vw, 22px);
  line-height: 1.15;
  font-weight: 900;
  text-align: center;
  background: transparent;
}

/* ---------- PLAY BUTTON ---------- */

.play-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: auto;
    height: auto;

    padding: 0;
    margin: 0;
    margin-top: -50px;

    border: none;
    background: transparent;
    box-shadow: none;

    cursor: pointer;

    transition: transform .15s ease;
}

.play-button img{
    width: min(360px,70vw);
    display:block;

    pointer-events:none;

    transition:
        transform .15s ease,
        filter .15s ease;
}

/* Hover */

.play-button:hover{
    transform: translateY(-6px);
}

/* Click */

.play-button:active{
    transform: translateY(4px) scale(.98);
}

/* Remove the generic button styling ONLY for the Play button */

.big-button.play-button{
    border:none !important;
    background:transparent !important;
    box-shadow:none !important;
}

/* Login / create account */
.login-card {
  width: min(500px, 92vw);
  padding: 18px 24px;
}

.guest-button {
  padding: 14px 42px;
  width: min(420px, 90vw);
  margin-bottom: 22px;
  color: var(--ink);
  font-size: clamp(24px, 4vw, 38px);
}

.or-text {
  margin-top: 12px;
  margin-bottom: -12px;
  font-size: 22px;
  font-weight: 900;
}

.social-login {
  display: grid;
  gap: 12px;
  width: min(420px, 90vw);
  margin: 0 auto 18px;
}

.social-button {
  height: 48px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffffff;
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 4px 5px 0 var(--shadow);
}

.apple-button {
  background: #111111;
  color: #ffffff;
}

.login-form {
  width: min(420px, 90vw);
  margin: 0 auto;
  text-align: left;
}

.login-form label,
.config-row span,
.check-row,
.generation-options legend {
  display: block;
  margin: 10px 0 4px;
  font-size: 20px;
}

.login-form input[type="text"],
.login-form input[type="password"],
.config-row input,
.config-row select,
.pokedex-controls input,
.pokedex-controls select,
.guess-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06);
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  outline: none;
}

.remember-row,
.captcha-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.remember-row {
  justify-content: flex-end;
  margin-top: 10px !important;
  font-size: 18px !important;
}

.captcha-row {
  justify-content: center;
  margin-top: 20px !important;
}

.remember-row input,
.check-row input,
.captcha-row input,
.generation-options input,
.mode-options input {
  width: 22px;
  height: 22px;
  accent-color: var(--green);
}

.login-button {
  display: block;
  width: min(418px, 90vw);
  margin: 24px auto 0;
  padding: 16px 24px;
  background: var(--green);
  font-size: 36px;
}

.create-text {
  margin-top: 18px;
  font-size: 21px;
  line-height: 1.25;
}

.form-error {
  min-height: 24px;
  margin: 0px 0 8px;
  color: #a12929;
  text-align: center;
  font-size: 17px;
}

.page-title {
  margin: 0 0 18px;
  font-size: clamp(38px, 6vw, 60px);
}

.back-mini {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 22px;
}

/* Account page */
.account-page {
  position: relative;
  padding: 86px 7vw 72px;
}

.back-arrow {
  position: absolute;
  top: 34px;
  left: 44px;
  color: var(--ink);
  font-size: 70px;
  line-height: 0.7;
  transform: scaleX(1.25);
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.16));
}

.account-actions {
  position: absolute;
  top: 46px;
  right: 6vw;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.new-game-button,
.join-game-button,
.small-action {
  padding: 14px 24px;
  font-size: clamp(18px, 2.4vw, 28px);
  white-space: nowrap;
}

.account-layout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(28px, 5vw, 58px);
  margin-top: 96px;
  background: transparent;
}

.avatar {
  position: relative;
  width: clamp(210px, 25vw, 300px);
  height: clamp(210px, 25vw, 300px);
  flex: 0 0 auto;
  overflow: hidden;
  border: 5px solid var(--ink);
  border-radius: 47% 53% 50% 46%;
  background: #ffffff;
  box-shadow: 6px 8px 0 var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.avatar:hover {
  transform: rotate(-1deg) translateY(-3px);
  box-shadow: 0 10px 0 var(--shadow);
}

.avatar-head {
  position: absolute;
  top: 78px;
  left: 50%;
  width: 78px;
  height: 78px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--ink);
}

.avatar-body {
  position: absolute;
  bottom: -20px;
  left: 50%;
  width: 150px;
  height: 150px;
  transform: translateX(-50%);
  border-radius: 50% 50% 18px 18px;
  background: var(--ink);
}

.avatar-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fafafa;
}

.avatar.has-avatar .avatar-head,
.avatar.has-avatar .avatar-body {
  display: none;
}

.avatar-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  width: max-content;
  max-width: 80%;
  padding: 8px 12px;
  transform: translateX(-50%);
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.avatar:hover .avatar-hint {
  opacity: 1;
}

.account-info h1 {
  margin: 0 0 16px;
  font-size: clamp(42px, 6vw, 72px);
  text-shadow: 2px 3px 0 rgba(0, 0, 0, 0.08);
}

.account-info p {
  margin: 8px 0;
  font-size: clamp(20px, 2.2vw, 29px);
}

.small-button {
  margin-top: 32px;
  padding: 11px 18px;
  font-size: 18px;
}

.pokedex-button {
  margin-left: 14px;
}

/* Modals and game config */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(40, 28, 12, 0.18);
  backdrop-filter: blur(2px);
}

.hidden {
  display: none !important;
}

.config-modal,
.join-modal,
.avatar-modal,
.score-modal {
  position: relative;
  background: linear-gradient(180deg, var(--panel-strong, #fffdf7), var(--panel));
  border: 5px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 10px 0 var(--shadow), 0 18px 34px rgba(0, 0, 0, 0.16);
}

.join-modal {
    position: relative;

    width: min(420px, 90vw);

    padding: 28px;

    background: var(--panel);

    border: 5px solid var(--ink);
    border-radius: 28px;

    box-shadow: 0 10px 0 var(--shadow);

    display: flex;
    flex-direction: column;
    gap: 14px;
}

.config-modal {
  width: min(760px, 92vw);
  max-height: min(86vh, 860px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 42px 42px 34px;
}

.close-button {
    position: absolute;

    top: 18px;
    right: 18px;

    width: 44px;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 4px solid #111;
    border-radius: 50%;

    background: white;

    font-size: 24px;
    font-weight: 900;

    cursor: pointer;

    box-shadow: 0 4px 0 #111;

    z-index: 20;
}

.generation-options {
  border: 0;
  padding: 8px 0 0;
  margin: 0;
}

.generation-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 8px 0;
  font-size: 21px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.mode-options {
    margin-top: 6px;
    padding: 12px 18px 14px;

    border: 4px solid var(--ink);
    border-radius: 20px;

    background: rgba(255,255,255,.45);
}

.mode-options legend {
  padding: 0 10px;
  color: var(--ink);
  font-size: 18px;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 8px;
}

.mode-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-column label {
    display: flex;
    align-items: center;
    gap: 10px;

    margin: 2px 0;

    font-size: 18px;

    white-space: nowrap;
}

.mode-column input[type="radio"] {
    flex-shrink: 0;
}

.mode-column h3 {
    margin: 0 0 8px;
    font-size: 20px;
}

.mode-options label {
    margin: 4px 0;
}

.lobby-code-row input {
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.helper-text {
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.start-button {
  position: static !important;
  align-self: center;
  transform: none !important;
  margin-top: 8px;
  padding: 12px 42px;
  background: #ffffff !important;
  font-size: 34px;
  line-height: 1;
}

/* Canvas page */
.canvas-page .topbar,
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 24px 48px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
}

.top-pokemon-name {
  margin: 0;
  text-align: center;
  text-transform: capitalize;
  font-size: clamp(28px, 4vw, 46px);
}

.top-right-actions,
.round-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.timer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  border: 4px solid #000000;
  border-radius: 52% 48% 47% 53%;
  background: #ffffff;
  box-shadow: 5px 6px 0 var(--shadow);
  font-size: 32px;
  font-weight: 900;
}

#doneBtn,
#giveUpBtn {
  margin: 0;
  padding: 9px 14px;
  border-width: 3px;
  border-radius: 14px;
  font-size: 15px;
}

#doneBtn {
  background: var(--green);
}

.game {
  display: grid;
  grid-template-columns: 150px 1fr 300px;
  gap: 24px;
  padding: 20px 48px 48px;
}

.toolbar,
.canvas-container,
.reference {
  background: rgba(255, 255, 255, 0.88);
  border: 3px solid #000000;
  border-radius: 18px;
  box-shadow: 0 7px 0 var(--shadow), 0 10px 24px rgba(0, 0, 0, 0.08);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.toolbar button {
  padding: 9px 10px;
  border-width: 2px;
  border-radius: 12px;
  font-size: 14px;
}

.toolbar button.active-tool {
  background: #ffe7a8;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #000000;
}

.toolbar label {
  font-weight: 900;
  font-size: 14px;
}

.canvas-container {
  padding: 16px;
}

canvas {
  width: 100%;
  height: 500px;
  border-radius: 14px;
  background: #fafafa;
  cursor: crosshair;
}

.reference {
  padding: 18px;
}

.reference h2,
.reference h3 {
  margin: 0 0 16px;
  text-transform: capitalize;
}

.reference img {
  width: 100%;
  min-height: 180px;
  padding: 20px;
  border-radius: 16px;
  background: transparent;
  box-sizing: border-box;
}

.multiplayer-side .helper-text {
  padding: 10px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
}

.guess-log {
  height: 220px;
  overflow-y: auto;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #ffffff;
  padding: 10px;
  margin-bottom: 12px;
  font-size: 15px;
}

.guess-log p {
  margin: 0 0 8px;
}

.spectator-canvas {
  cursor: default;
  opacity: 0.95;
}

.toolbar button:disabled,
.toolbar input:disabled,
#doneBtn:disabled,
#giveUpBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Pokédex page */
.pokedex-page {
  position: relative;
  padding: 72px 7vw;
}

.pokedex-layout {
  width: min(1100px, 92vw);
  margin: 70px auto 0;
  background: transparent;
}

.pokedex-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.pokedex-header h1 {
  margin: 0;
  font-size: clamp(54px, 8vw, 90px);
  text-shadow: 2px 3px 0 rgba(0, 0, 0, 0.08);
}

.pokedex-header p {
  margin: 0 0 14px;
  font-size: clamp(20px, 3vw, 32px);
}

.pokedex-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 190px 190px;
  gap: 16px;
  margin-bottom: 24px;
}

.pokedex-controls input,
.pokedex-controls select {
  height: 50px;
  font-size: 16px;
}

.pokedex-list {
  display: grid;
  gap: 14px;
  max-height: 68vh;
  overflow-y: auto;
  padding: 0 10px 20px 0;
}

.loading-text {
  font-size: 26px;
}

.pokedex-entry {
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 7px 0 var(--shadow);
}

.pokedex-entry summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  font-size: 22px;
  text-transform: capitalize;
}

.pokedex-entry summary::-webkit-details-marker {
  display: none;
}

.pokedex-entry summary::before {
  content: "+";
  margin-right: 10px;
  font-size: 28px;
}

.pokedex-entry[open] summary::before {
  content: "-";
}

.pokedex-entry.drawn .draw-status {
  color: #4f7d1f;
}

.pokedex-entry.missing .draw-status {
  color: #8a8a8a;
}

.sketch-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
  padding: 0 22px 22px;
}

.sketch-gallery figure {
  margin: 0;
  padding: 10px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
}

.sketch-gallery img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 10px;
  background: #fafafa;
}

.sketch-gallery figcaption,
.empty-gallery {
  margin: 8px 0 0;
  font-size: 14px;
}

.empty-gallery {
  padding: 0 22px 22px;
  color: #777777;
}

/* Score and avatar modals */
.score-modal {
  width: min(430px, 90vw);
  padding: 34px 28px;
  text-align: center;
}

.score-modal h2 {
  margin: 0 0 12px;
  font-size: 34px;
}

.score-number {
  display: grid;
  place-items: center;
  width: 170px;
  min-height: 84px;
  margin: 10px auto 14px;
  border: 5px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 6px 0 var(--shadow);
  font-size: 36px;
  font-weight: 900;
}

.score-modal p {
  margin: 10px 0 22px;
  font-size: 18px;
  line-height: 1.35;
}

.avatar-modal {
  width: min(820px, 92vw);
  max-height: 82vh;
  overflow: auto;
  padding: 42px;
}

.avatar-modal h2 {
  margin: 0 0 8px;
  font-size: 34px;
}

.avatar-modal p {
  font-size: 18px;
}

.avatar-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.avatar-choice {
  padding: 10px;
  text-transform: capitalize;
}

.avatar-choice img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 12px;
  background: #fafafa;
}

/* Responsive */
@media (max-width: 1000px) {
  .game {
    grid-template-columns: 1fr;
  }

  .canvas-page .topbar,
  .topbar {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .top-right-actions,
  .round-actions {
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .account-layout,
  .topbar {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .account-actions {
    position: static;
    justify-content: center;
    margin: 30px auto 0;
  }

  .new-game-button {
    position: static;
    display: block;
    margin-left: auto;
  }

  .pokedex-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .config-modal {
    padding: 38px 22px 28px;
  }

  .config-row,
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .close-button {
    margin-right: -8px;
  }

  .account-layout {
    justify-content: center;
    margin-top: 42px;
    text-align: center;
  }
}

@media (max-width: 700px) {
  .pokedex-header,
  .pokedex-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pokedex-entry summary {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 560px) {
  .pokedex-controls {
    grid-template-columns: 1fr;
  }

  .round-actions,
  .top-right-actions {
    flex-direction: column;
  }

  .logo {
    margin-bottom: -70px;
  }
}

/* Requested polish pack */
.undo-redo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.undo-redo-row button {
  min-width: 0;
  padding: 8px 0;
  font-size: 24px;
  line-height: 1;
}

/* Account layout: avatar sits directly beside username */
.account-layout {
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr);
  align-items: center;
  gap: 28px;
  width: min(980px, 88vw);
}

.avatar {
  width: clamp(160px, 18vw, 230px);
  height: clamp(160px, 18vw, 230px);
}

.account-info h1 {
  margin-bottom: 8px;
}

.account-actions {
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.account-button-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Hide old save-data tools if they exist in older copies */
.data-actions,
#exportDataBtn,
#importDataInput,
#resetDataBtn,
.import-label,
.danger-button {
  display: none !important;
}

/* Daily Challenge cards */
.daily-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "img kicker button"
    "img name button";
  align-items: center;
  gap: 3px 12px;
  padding: 12px 14px;
  border: 4px solid var(--ink);
  border-radius: 22px 18px 24px 17px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 5px 6px 0 var(--shadow);
  z-index: 10;
  animation: dailyWiggle 6s infinite;
  transform-origin: center;
}

.daily-home-card {
  position: fixed;
  top: 26px;
  right: 26px;
  width: min(330px, calc(100vw - 52px));
}

.daily-account-card {
  width: min(330px, 90vw);
}

.daily-kicker {
  grid-area: kicker;
  font-size: 14px;
  font-weight: 900;
  color: var(--muted);
  line-height: 1;
}

.daily-image {
  grid-area: img;
  width: 62px;
  height: 62px;
  object-fit: contain;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: white;
}

.daily-card strong {
  grid-area: name;
  font-size: 21px;
  line-height: 1.05;
  text-transform: capitalize;
}

.daily-play-button {
  grid-area: button;
  margin: 0;
  padding: 8px 12px;
  border-width: 3px;
  border-radius: 14px;
  font-size: 16px;
  box-shadow: 3px 4px 0 var(--shadow);
  background: var(--green);
}

@keyframes dailyWiggle {
  0%, 88%, 100% { transform: rotate(0deg) translateX(0); }
  90% { transform: rotate(-1.6deg) translateX(-1px); }
  92% { transform: rotate(1.8deg) translateX(2px); }
  94% { transform: rotate(-1deg) translateX(-1px); }
  96% { transform: rotate(1deg) translateX(1px); }
}

/* Pokédex drawing hover tools */
.sketch-card {
  position: relative;
  overflow: hidden;
}

.sketch-actions {
  position: absolute;
  inset: auto 10px 46px 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none;
}

.sketch-card:hover .sketch-actions,
.sketch-card:focus-within .sketch-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.sketch-maximize,
.sketch-download {
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  padding: 5px 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 2px 3px 0 var(--shadow);
}

.sketch-lightbox {
  z-index: 2000;
}

.sketch-lightbox-card {
  position: relative;
  width: min(760px, 92vw);
  max-height: 88vh;
  padding: 28px;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 8px 10px 0 var(--shadow);
  text-align: center;
}

.sketch-lightbox-card h2 {
  margin: 0 0 14px;
}

.sketch-lightbox-card img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border: 4px solid var(--ink);
  border-radius: 16px;
  background: white;
}

@media (max-width: 900px) {
  .account-layout {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .account-actions {
    align-items: center;
  }

  .daily-home-card {
    position: static;
    margin: 18px auto 0;
  }
}

/* Restored account stats and achievements */
.profile-extras {
  margin-top: 28px;
  max-width: 720px;
}

.profile-extras h2 {
  margin: 22px 0 10px;
  font-size: 30px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 12px;
}

.stats-grid div,
.achievement {
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 3px 4px 0 var(--shadow);
}

.stats-grid div {
  padding: 10px;
  text-align: center;
}

.stats-grid strong {
  display: block;
  font-size: 28px;
}

.stats-grid span {
  display: block;
  font-size: 15px;
}

.achievement-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.achievement {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  padding: 10px 12px;
  align-items: center;
}

.achievement small {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
}

.achievement.locked {
  opacity: 0.58;
}

@media (max-width: 760px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Detailed AI scoring breakdown */
.detailed-score-modal {
  width: min(520px, 92vw);
}

.score-breakdown {
  width: min(390px, 100%);
  margin: 12px auto 16px;
  display: grid;
  gap: 9px;
  text-align: left;
}

.score-row {
  display: grid;
  grid-template-columns: 105px 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
}

.score-label {
  white-space: nowrap;
}

.score-bar-text {
  letter-spacing: 1px;
  white-space: nowrap;
  font-family: "Courier New", monospace;
  font-size: 16px;
  line-height: 1;
}

.score-value {
  text-align: right;
}

.score-bar-track {
  grid-column: 2 / 4;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.15);
}

.score-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

@media (max-width: 520px) {
  .score-row {
    grid-template-columns: 1fr 48px;
  }

  .score-label {
    grid-column: 1 / 2;
  }

  .score-bar-text {
    display: none;
  }

  .score-value {
    grid-column: 2 / 3;
  }

  .score-bar-track {
    grid-column: 1 / 3;
  }
}

/* Account profile alignment fix */

.account-page {
  padding-top: 110px;
}

.account-layout {
  display: grid;
  grid-template-columns: 260px minmax(520px, 1fr);
  grid-template-areas:
    "avatar info"
    "extras extras";
  align-items: start;
  gap: 28px 36px;
  width: min(1060px, 88vw);
  margin: 120px auto 0;
}

.avatar {
  grid-area: avatar;
  width: 260px;
  height: 260px;
  align-self: start;
}

.account-info {
  grid-area: info;
  padding-top: 0;
}

.account-info h1 {
  margin-top: 0;
  line-height: 1;
}

.account-info .profile-extras {
  grid-area: extras;
}

.profile-extras {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
  margin-top: 18px;
}

.profile-extras h2,
.stats-grid,
.achievement-list {
  width: 100%;
}

.profile-extras h2 {
  text-align: left;
}

.stats-grid,
.achievement-list {
  margin-left: 0;
  position: relative;
}

/* Keep account buttons on the right */
.account-actions {
  top: 46px;
  right: 6vw;
}

/* Responsive fallback */
@media (max-width: 900px) {
  .account-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "avatar"
      "info"
      "extras";
    justify-items: center;
    text-align: center;
    margin-top: 80px;
  }

  .profile-extras h2 {
    text-align: center;
  }
}
/* Login + create account update */
.create-account-page .login-card {
  margin-top: 0;
}

.auth-back-arrow {
  position: fixed;
  top: 34px;
  left: 44px;
  z-index: 5;
}

.login-form input[type="email"],
.forgot-modal input[type="text"],
.forgot-modal input[type="email"],
.forgot-modal input[type="password"] {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06);
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  outline: none;
}

.forgot-password-link {
  margin-right: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--blue);
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.forgot-password-link:hover {
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}

.forgot-modal {
  position: relative;
  width: min(440px, 92vw);
  padding: 34px 30px 30px;
  border: 5px solid var(--ink);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 10px 0 var(--shadow), 0 18px 34px rgba(0, 0, 0, 0.16);
}

.forgot-modal h2 {
  margin: 0 56px 10px 0;
  font-size: 34px;
}

.forgot-help {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.25;
}

.forgot-modal label {
  display: block;
  margin: 12px 0 5px;
  font-size: 20px;
  font-weight: 900;
}

.forgot-modal .small-button {
  display: block;
  margin: 22px auto 0;
}

#forgotMessage,
#resetMessage {
  min-height: 28px;
  margin-top: 14px;
  line-height: 1.25;
}

#forgotMessage a {
  font-weight: 900;
}


/* Mobile / Android drawing fixes */
html {
  -webkit-text-size-adjust: 100%;
}

body.canvas-page {
  overscroll-behavior: none;
}

.canvas-container,
.canvas-container canvas,
#canvas {
  touch-action: none;
  -ms-touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#canvas {
  display: block;
  max-width: 100%;
}

@media (max-width: 760px) {
  body.canvas-page {
    min-height: 100svh;
    overflow-x: hidden;
  }

  .canvas-page .topbar,
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 14px 8px;
  }

  .topbar h1 {
    font-size: 28px;
    text-align: center;
  }

  .top-pokemon-name {
    font-size: 32px;
    line-height: 1;
  }

  .top-right-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    width: 100%;
    gap: 8px;
  }

  #doneBtn,
  #giveUpBtn {
    width: 100%;
    padding: 8px 10px;
    font-size: 16px;
  }

  .timer {
    width: 58px;
    height: 58px;
    font-size: 24px;
  }

  .game {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 8px 12px 24px;
  }

  .toolbar {
    order: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(72px, 1fr));
    gap: 8px;
    padding: 10px;
    align-items: center;
  }

  .toolbar label {
    font-size: 13px;
    margin: 0;
  }

  .toolbar input[type="range"],
  .toolbar input[type="color"] {
    width: 100%;
  }

  .toolbar button {
    min-height: 42px;
    padding: 7px 8px;
    font-size: 14px;
  }

  .undo-redo-row {
    grid-column: span 1;
  }

  .canvas-container {
    order: 2;
    padding: 8px;
    border-width: 3px;
  }

  canvas,
  #canvas {
    width: 100%;
    height: min(62svh, 520px);
    min-height: 360px;
    background: #ffffff;
  }

  .reference {
    order: 3;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: center;
    padding: 10px 12px;
  }

  .reference h3 {
    margin: 0;
    font-size: 20px;
  }

  .reference img {
    justify-self: end;
    width: 110px;
    min-height: 0;
    padding: 4px;
  }
}

@media (max-width: 430px) {
  .toolbar {
    grid-template-columns: repeat(3, minmax(70px, 1fr));
  }

  canvas,
  #canvas {
    height: 58svh;
    min-height: 320px;
  }
}

/* iOS / installed-app polish */
html {
  min-height: 100%;
  background: #fffdf7;
}

body {
  min-height: 100svh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Prevent Home Screen mode from hiding controls behind the notch/home indicator. */
@media (display-mode: standalone) {
  .topbar {
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .account-page,
  .pokedex-page {
    padding-top: max(86px, calc(env(safe-area-inset-top) + 52px));
    padding-bottom: max(72px, calc(env(safe-area-inset-bottom) + 24px));
  }

  .center-page {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* iPhone Safari Add to Home Screen helper. Injected only when useful. */
.ios-install-tip {
  position: fixed;
  z-index: 5000;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: min(390px, calc(100vw - 28px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 44px 1fr 32px;
  gap: 10px;
  align-items: center;
  padding: 12px 12px 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 18px 22px 16px 20px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 5px 6px 0 var(--shadow), 0 12px 32px rgba(0,0,0,.16);
  animation: iosTipIn .25s ease-out;
}

.ios-install-tip img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.ios-install-copy {
  min-width: 0;
  font-size: 15px;
  line-height: 1.18;
}

.ios-install-copy strong {
  display: block;
  margin-bottom: 2px;
  font-size: 17px;
}

.ios-install-copy .share-glyph {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 800;
}

.ios-install-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
}

@keyframes iosTipIn {
  from { opacity: 0; transform: translate(-50%, 18px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 700px) {
  .ios-install-tip {
    bottom: calc(10px + env(safe-area-inset-bottom));
  }
}
