/** Random reset, let's see if it helps */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, menu, nav, output, section, summary, time, mark, audio, video {
    position: relative;
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
}

div {
    box-sizing: border-box;
}

button {
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

body {
    background: #68427a;

    font-family: "IM Fell English", serif;
    /* font-family: "Balthazar", serif;
    font-family: "Bellefair", serif; */

    --tray-background: #ddd;
    --active-color: #da1212;
    --dark-purple: #1c0d22;
    --square-size: 28px;
    --column-size: calc(var(--square-size) + 6px); /* 28 + 2 * (1px padding + 2px border) */
    --puzzle-top: 120px;
}

.box .icon {
    margin-right: 5px;
    margin-bottom: -5px;
}

.puzzle-backdrop {
    position: fixed;
    top: var(--puzzle-top);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--dark-purple);
    z-index: 9;
    pointer-events: none;
    transition: top 300ms;
}

#game:not(.show-puzzle) .puzzle-backdrop,
#game.complete .puzzle-backdrop {
    top: 1000px;
}

.puzzle-wrapper {
    position: absolute;
    top: var(--puzzle-top);
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    overflow: hidden;
}

.complete .puzzle-wrapper {
    pointer-events: none;
}

.puzzle-date-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    top: -35px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

.puzzle-date {
    font-family: "IM Fell English SC", serif;
    width: 200px;
    text-align: center;
    background: var(--dark-purple);
    color: white;
    border-radius: 10px 10px 0 0;
    padding: 4px 0 10px;
}

.puzzle-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    background: var(--dark-purple);
    box-shadow: 0px -2px 1px black;
    padding: 10px 0;
    border-top: 4px double #444;

    transform: translateY(0);
    transition: transform 300ms;
}

#game.complete .puzzle-container {
    background: transparent;
    box-shadow: none;
}

#game:not(.show-puzzle) .puzzle-container {
    transform: translateY(1000px);
}

.puzzle-area {
    width: 100%;
    overflow-x: auto;
}

/* During complete animation, need to hide scrollbar and center with flex isntead */
#game.complete .puzzle-area {
    overflow-x: visible;
    display: flex;
    justify-content: center;
}

.puzzle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: fit-content;
    margin: 0 auto;
    padding: 20px 0 25px;
    --row-count: 4;
    --col-min-height: calc(var(--square-size) * (var(--row-count) + 0.5));
    transform-origin: center;
}

.puzzle:not(.editable) {
    pointer-events: none;
}

.column {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: var(--column-size);
    min-height: var(--col-min-height);
    padding: 2px 1px;
    background: var(--tray-background);
    border: 2px inset #666;
    border-top: none;
    border-bottom-width: 4px;
}

.column:first-child {
    width: calc(var(--column-size) + 2px);
    border-left-width: 4px;
}
.column:last-child {
    width: calc(var(--column-size) + 2px);
    border-right-width: 4px;
}

.row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.subrow {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.grid .row {
    border: 4px inset #999;
    background: var(--tray-background);
}

.square-wrapper {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: height 200ms linear;
}

.square {
    --inner-size: calc(var(--square-size) - 2px);
    width: var(--inner-size);
    height: var(--inner-size);
    border: 4px outset transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "IM Fell English", serif;
    font-size: 16px;
    background: var(--tray-background);
    user-select: none;
    transition: scale 50ms;
}

.editable .square.type:hover {
    transform: scale(1.1);
}

.blank.square {
    background: #333;
}

/* .blank.square::after {
    content: "";
    position: absolute;
    pointer-events: none;
    height: 38px;
    width: 1px;
    background: #888;
    transform: rotate(45deg);
} */

.square.type {
    background: #666;
    color: white;
    border-color: #555;
    transition: color 50ms;
    overflow: hidden;
}

.square.type.inked {
    color: black;
}

.letters {
    display: flex;
    flex-direction: row;
    margin-bottom: 15px;
}

#letters.shake {
    animation: vertical-shake 400ms ease-in;
}

#grid.shake {
    animation: shake 300ms ease-in;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

@keyframes vertical-shake {
    0% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    50% { transform: translateY(5px); }
    75% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

@keyframes bounce {
    0% { transform: scale(1) }
    50% { transform: scale(1.02) }
    100% { transform: scale(1) }
}

.bounce {
    animation: bounce 200ms ease-in-out;
}

.grid {
    display: flex;
    flex-direction: column;
    width: 760px;
    justify-content: flex-start;
    align-items: center;
}

.grid .square-wrapper {
    width: var(--column-size);
    height: var(--column-size);
    border: 1px solid #888;
}

.grid .square {
    transform: scale(1.25); /* fill wrapper */
}

.editable .grid .square.type:hover {
    transform: scale(1.3);
}

.square.active {
    transform: scale(1.1);
    outline: 4px solid var(--active-color);
    border-radius: 2px;
    z-index: 1;
}

.grid .square.active {
    transform: scale(1.3);
}

.letters .used {
    visibility: hidden;
    height: 0;
}

.editable .square:not(.blank) {
    cursor: pointer;
}

.moving-letter {
    position: fixed;
    z-index: 50;
    pointer-events: none;
}

.moving-letter .square.big {
    transform: scale(1.25);
}

.active-actions {
    padding-top: 10px;
    transition: all 100ms;
}

.complete .active-actions {
    opacity: 0;
}

.active-actions .row {
    gap: 10px;
}

.active-actions .action {
    background: seashell;
    width: 170px;
    text-wrap: nowrap;
}

.active-actions .icon {
    color: #865a9c;
}

.active-actions .secondary .icon {
    color: #b94a4a;
}

#game.replay #complete-button {
    display: none;
}
#game:not(.replay) #cancel-button {
    display: none;
}

#game {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow: auto;
    padding-top: 10px;
}

.newspaper, .actions {
    transition: opacity 100ms;
}

.show-puzzle .newspaper,
#grid:not(.complete) .newspaper,
.show-puzzle .actions,
#grid:not(.complete) .actions,
.show-puzzle #complete-section,
#grid:not(.complete) #complete-section
{
    transition: none;
    opacity: 0;
}

.newspaper-bg {
    position: absolute;
    top: 10px;
    bottom: 0;
    width: 450px;
    box-shadow: 0px -1px 4px black;
    outline: 1px solid black;
}

.newspaper-bg.main {
    box-shadow: 0 -1px 6px black;
}

.newspaper-page {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    width: 100%;
    max-width: 450px;
    background: seashell;
    font-size: 16px;
}

.heading {
    padding: 8px 0;
    text-align: center;
    user-select: none;
}

.title {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

h1 {
    font-size: 50px;
    font-family: "Manufacturing Consent", serif;
    padding: 4px;
    flex: 1;
}

@media (max-width: 430px) {
    h1 {
        font-size: 38px;
    }
}

.box {
    border: 1px solid black;
    padding: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "IM Fell English SC", serif;
}

.heading-box {
    width: 60px;
    height: 40px;
    margin: 8px 8px 10px;
    font-size: 9px;
}

#slogan {
    font-family: "IM Fell English", serif;
    border: none;
    padding: 0;
    padding-left: 5px;
}

#how-to-play {
  font-size: 13px;
  cursor: pointer;
  padding: 3px;
}

.date-nav {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border-top: 4px double black;
    border-bottom: 4px double black;
    padding: 3px 10px;
    font-family: "IM Fell English SC", serif;
    font-size: 12px;
    font-style: italic;
    height: 40px;
    margin: 0 1px;
}

.date-nav .nav {
    flex: 1;
    opacity: 0.5;
    transition: all 50ms ease-out;
}

.date-nav .active {
    cursor: pointer;
    opacity: 1;
}

.date-nav .nav:not(.active) {
    pointer-events: none;
}

.date-nav .active:hover {
    transform: scale(1.05);
}

.current-date {
    min-width: 190px;
    font-size: 18px;
    font-style: normal;
    cursor: default;
}

.date-nav .current-date {
    flex: 1;
}

.date-nav .arrow {
    font-size: 30px;
    font-style: normal;
    margin: -10px 0;
}

.date-nav .arrow.active:hover {
    transform: scale(1.1);
}

.date-nav .shortcut {
    flex: none;
    width: 60px;
}

.date-nav #today {
    text-align: end;
}

#archive-button {
    text-align: start;
    transition: all 100ms ease-in-out;
}

.newspaper {
    padding: 5px 20px 0;
}

.headline {
    text-align: center;
    text-transform: uppercase;
    font-weight: bold;
    word-spacing: 0.25em;
    padding: 10px 0 0;
    margin-bottom: 10px;
}

h2 {
    font-size: 22px;
}

hr {
    width: 40%;
    margin: 5px 0;
    align-self: center;
}

hr.divider {
    width: 100%;
}

.article {
    text-align: justify;
    line-height: 1.5;
    text-indent: 1em;
    margin-top: 10px;
}

.article p {
    text-align: justify;
    margin-bottom: 0.5em;
}

.complete-actions {
    display: flex;
    flex-direction: column;
}

.actions {
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    align-items: stretch;
    padding: 10px 20px 20px;
}

h3.headline {
    padding: 0;
    margin-bottom: 5px;
    font-size: 14px;
}

#complete-article {
    border-right: 1px solid black;
    padding-right: 30px;
}

.actions .article {
    text-indent: 0;
    padding: 0 10px;
    margin: 5px 0;
}

.actions hr {
    width: 20%;
}

.actions .row {
    gap: 15px;
}

.action {
    cursor: pointer;
    font-size: 15px;
    font-family: "IM Fell English SC", serif;
    padding: 6px 10px;
    transition: transform 50ms ease-out;
    background: seashell;
    color: black;
    border-radius: 2px;
}

.actions .action {
    width: 100px;
}

.action.disabled {
    opacity: 0.5;
    pointer-events: none;
}

#open-share-button {
    border: 2px solid black;
}

.action:hover {
    transform: scale(1.03);
}

#hint {
    width: 170px;
}

#hint div {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

#hint:not(.active) #select-hint {
    display: none;
}

#hint.active #reveal-hint {
    display: none;
}

#hint.active {
    outline: 4px solid var(--active-color);
    border-radius: 2px;
}

.footer {
    height: 20px;
    border-top: 4px double black;
}

.full-reveal .headline,
.full-reveal .article {
    display: none;
}

.full-reveal #open-share-button {
    opacity: 0.5;
    pointer-events: none;
    border-width: 1px;
}

#start-overlay {
    background: black;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 800ms;
    z-index: 20;
}

#start-overlay.start {
    opacity: 1;
}

.modal-overlay {
    background: rgba(0, 0, 0, 0.3);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    width: 380px;
    background: var(--dark-purple);
    color: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 1px 1px 4px black;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    user-select: none;
    overflow: auto;
}

#share-modal {
    gap: 5px;
}

.close-modal {
    position: absolute;
    top: 6px;
    right: 8px;
    cursor: pointer;
    opacity: 0.6;
    font-size: 12px;
}

.close-modal:hover {
    opacity: 0.9;
}

.share-text-wrapper {
    background: seashell;
    color: black;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px dashed black;
    margin: 10px;
}

#share-text {
    border-top: 4px double black;
    border-bottom: 4px double black;
    padding: 10px 0;
    user-select: all;
    font-family: "Noto Sans", sans-serif;
    font-weight: 350;
    font-size: 15px;
    min-height: 110px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal h3 {
    font-family: "IM Fell English SC", serif;
    font-size: 26px;
    margin-bottom: 10px;
    text-align: center;
}

h4 {
    font-family: "IM Fell English SC", serif;
    border-bottom: 1px solid black;
    margin: 5px 0;
    font-size: 18px;
}

.modal .row {
    gap: 15px;
    margin-bottom: 5px;
}

#discord {
    text-decoration: none;
}

#copied-text, #copy-failed {
    display: none;
}

.copy-success #copied-text {
    display: flex;
    color: #a8f1a8;
}
.copy-failed #copy-failed {
    display: flex;
    color: #ff9e9e;
}

.warning {
    font-size: 12px;
    height: 20px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-end;
}

.title-text {
    font-family: "Manufacturing Consent", serif;
    font-size: 30px;
}

#welcome-actions {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 15px;
    margin: 8px 0 12px;
}

#reveal-all {
    align-self: center;
    margin-top: 5px;
    width: 180px;
}

#welcome-modal:not(.has-revealed-all) #revealed-button-text {
    display: none;
}

#welcome-modal.has-revealed-all #reveal-button-text {
    display: none;
}

#this-week-button {
    border-width: 2px;
}

.has-revealed-all #this-week-button {
    border-width: 1px;
}

.has-revealed-all #today-button {
    border-width: 2px;
}

#welcome-modal {
    background: seashell;
    color: black;
    align-items: stretch;
}

#welcome-overlay {
    justify-content: flex-start;
    padding: 20px;
}

#welcome-modal h3 {
    border-bottom: 4px double black;
}

.modal p {
    margin: 5px 0;
    text-align: justify;
}

#input-instructions-tap {
    display: none;
}

#landscape-warning {
    display: none;
}

@media (hover: none) {
    #input-instructions-type {
        display: none;
    }
    #input-instructions-tap {
        display: inline;
    }
}

@media (hover: none) and (orientation: portrait) {
  #landscape-warning {
    display: block;
  }
}

#returning-player {
    display: flex;
    flex-direction: column;
}

.complete .column {
    transition: all 100ms;
    opacity: 0;
}

.complete #grid {
    transform: translateY(-150px) scale(1.1);
    transition: all 1300ms ease-in-out;
}

#grid.stamp {
    transform: translateY(-150px) scale(0.8);
    transition: all 100ms ease-in-out;
}

hr, #article, #complete-section {
    transition: all 300ms ease-in-out;
}

.hidden {
    opacity: 0;
}

.show-archive .newspaper-contents {
    display: none;
}

.show-archive .arrow, .show-archive #current-date {
    display: none;
}

.show-archive #archive-button {
    font-style: normal;
    font-size: 20px;
    text-align: center;
    flex: 1;
    margin-right: -60px;
    pointer-events: none;
}

#archive {
    padding: 0 10px 15px;
    display: none;
    height: 500px;
    overflow-y: auto;
}

.show-archive #archive {
    display: flex;
}

#archive-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 5px;
}

.archive-chapter-title {
    font-family: "Manufacturing Consent", serif;
    font-size: 22px;
    border-bottom: 2px double black;
    margin: 10px 0;
    flex: 1;
}

.archive-chapter {
    display: flex;
    flex-direction: column;
}

.archive-title-wrapper {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 5px;
}

.archive-title-wrapper .action {
    display: none;
}

.archive-day.archive-week {
    display: none;
}

.unsolved .archive-day {
    display: none;
}

/* .unsolved .archive-week {
    display: flex;
} */

.unsolved .archive-title-wrapper .action {
    display: flex;
}

.archive-day {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: 5px;
    /* font-family: "IM Fell English SC", serif; */
    font-size: 14px;
    height: 27px;
}

.archive-day .dots {
    flex: 1;
    border-bottom: 2px dotted black;
}

.archive .action {
    padding: 2px;
    margin: 2px;
    font-size: 14px;
    width: 45px;
    flex: none;
}

.archive .complete .action {
    border-color: #999;
}

/* .archive-day:not(.complete) .title {
    font-style: italic;
} */

.archive .unavailable .action {
    display: none;
}

.archive-day .title {
    text-transform: capitalize;
    text-wrap: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.archive-day .number {
    width: 2.5em;
    flex: none;
}

.archive-week .number {
    width: 5.5em;
}

.remaining-time {
    width: 45px;
    text-align: center;
    font-size: 14px;
    font-family: "IM Fell English SC", serif;
    margin: 2px;
    flex: none;
}

#archive-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px;
}

#archive-footer svg {
    width: 30px;
    height: 30px;
}

.newspaper-bg-wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.decorative.newspaper-bg {
    height: 500px;
    max-width: 50px;
    --direction: 1;
    --margin-adjust: 5px;
    --rotation: 2deg;
    top: 15px;
    margin-left: calc(400px + var(--margin-adjust));
    transform: rotate(calc(var(--rotation) * var(--direction)));
    transition: all 200ms ease-in-out;
}

.decorative.newspaper-bg:nth-child(odd) {
    --direction: -1;
    margin-left: 0;
    margin-right: calc(400px + var(--margin-adjust));
}

.decorative.newspaper-bg:nth-child(1),
.decorative.newspaper-bg:nth-child(2) {
    padding-top: 27px;
    --margin-adjust: 16px;
    top: 26px;
    --rotation: 3deg;
}

.decorative.newspaper-bg:nth-child(3),
.decorative.newspaper-bg:nth-child(4) {
    padding-top: 48px;
}

.show-puzzle .decorative.newspaper-bg:nth-child(1),
.show-puzzle .decorative.newspaper-bg:nth-child(2) {
    --margin-adjust: 50px;
    --rotation: 12deg;
    top: 80px;
}

.show-puzzle .decorative.newspaper-bg:nth-child(3),
.show-puzzle .decorative.newspaper-bg:nth-child(4) {
    --margin-adjust: 30px;
    --rotation: 6deg;
    top: 50px;
}

.decorative .date-nav {
    opacity: 0;
}

.show-puzzle .decorative .date-nav {
    opacity: 1;
}

@media (max-width: 600px) {
    .decorative.newspaper-bg {
        display: none;
    }
}